From 7619135618bf2b3c1698dec0294855f2b016ff7c Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 18 Dec 2015 09:41:44 +0100 Subject: Only show assignments of that offer in offer view --- classes/BusinessAdmin.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'classes/BusinessAdmin.class.php') 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 +} -- cgit v1.2.3