diff options
author | Camil Staps | 2015-12-18 09:41:44 +0100 |
---|---|---|
committer | Camil Staps | 2015-12-18 09:41:44 +0100 |
commit | 7619135618bf2b3c1698dec0294855f2b016ff7c (patch) | |
tree | e966b292d743bbfc8c202bfd5ae0a859a63bd6ec /classes/BusinessAdmin.class.php | |
parent | Fixed a bug where some offers aren't shown in active offers if they have simi... (diff) |
Only show assignments of that offer in offer view
Diffstat (limited to 'classes/BusinessAdmin.class.php')
-rw-r--r-- | classes/BusinessAdmin.class.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/classes/BusinessAdmin.class.php b/classes/BusinessAdmin.class.php index 20b95c4..d90e341 100644 --- a/classes/BusinessAdmin.class.php +++ b/classes/BusinessAdmin.class.php @@ -157,14 +157,15 @@ class BusinessAdmin { * @see BusinessAdmin::getAssignments() This funtion returns instances of the assignment class instead of just the ids * * @param PDO $pdo The PDO class for database connection + * @param string[] $where An array of WHERE clauses that will be AND-ed * * @throws PDOException Is something went wrong with the database * * @return int[] The ids */ - public static function getAssignmentIds($pdo) { + public static function getAssignmentIds($pdo, $where = array()) { $ids = array(); - $assignments = $pdo->query("SELECT `id` FROM `".constants::db_prefix."assignment`")->fetchAll(PDO::FETCH_ASSOC); + $assignments = $pdo->query("SELECT `id` FROM `".constants::db_prefix."assignment`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); foreach ($assignments as $assignment) { $ids[] = $assignment['id']; } @@ -177,13 +178,14 @@ class BusinessAdmin { * @see BusinessAdmin::getAssignmentIds() This function returns just the ids of the assignments, and not instances of the assignment class * * @param PDO $pdo The PDO class for database connection + * @param string[] $where An array of WHERE clauses that will be AND-ed * * @throws PDOException If something went wrong with the database * * @return assignment[] An array indexed by id of instances of the assignment class */ - public static function getAssignments($pdo) { - $ids = self::getAssignmentIds($pdo); + public static function getAssignments($pdo, $where = array()) { + $ids = self::getAssignmentIds($pdo, $where); $assignments = array(); foreach ($ids as $id) { $assignments[$id] = new assignment($pdo, $id); @@ -279,4 +281,4 @@ class BusinessAdmin { return $output; } -}
\ No newline at end of file +} |