summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-04-26 10:29:17 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-04-26 13:20:56 +0200
commit92812050a059a651357f772b58e967154ea8428c (patch)
treec7b61560011b3cbe0671c998b4ee0ce19fc40b22 /web/lib/pkgfuncs.inc.php
parent34453d32958cc71cf08e932368952f98b46b7020 (diff)
downloadaur-92812050a059a651357f772b58e967154ea8428c.tar.gz
aur-92812050a059a651357f772b58e967154ea8428c.tar.xz
Store conflicts, provides and replaces in the DB
Package conflicts, provides and replaces are now stored in the new PackageRelations table. The gendummydata script generates test entries for these relations. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 5c30a95a..2eb0be46 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -148,6 +148,21 @@ function pkg_dependency_type_id_from_name($name) {
}
/**
+ * Get the ID of a relation type given its name
+ *
+ * @param string $name The name of the relation type
+ *
+ * @return int The ID of the relation type
+ */
+function pkg_relation_type_id_from_name($name) {
+ $dbh = DB::connect();
+ $q = "SELECT ID FROM RelationTypes WHERE Name = ";
+ $q.= $dbh->quote($name);
+ $result = $dbh->query($q);
+ return $result->fetch(PDO::FETCH_COLUMN, 0);
+}
+
+/**
* Get the HTML code to display a package dependency link
*
* @param string $name The name of the dependency
@@ -727,6 +742,27 @@ function pkg_add_dep($pkgid, $type, $depname, $depcondition) {
}
/**
+ * Add a relation for a specific package to the database
+ *
+ * @param int $pkgid The package ID to add the relation for
+ * @param string $type The type of relation to add
+ * @param string $relname The name of the relation to add
+ * @param string $relcondition The version requirement of the relation
+ *
+ * @return void
+ */
+function pkg_add_rel($pkgid, $type, $relname, $relcondition) {
+ $dbh = DB::connect();
+ $q = sprintf("INSERT INTO PackageRelations (PackageID, RelTypeID, RelName, RelCondition) VALUES (%d, %d, %s, %s)",
+ $pkgid,
+ pkg_relation_type_id_from_name($type),
+ $dbh->quote($relname),
+ $dbh->quote($relcondition)
+ );
+ $dbh->exec($q);
+}
+
+/**
* Add a source for a specific package to the database
*
* @param int $pkgid The package ID to add the source for