aboutsummaryrefslogtreecommitdiff
path: root/classes/BusinessAdmin.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/BusinessAdmin.class.php')
-rw-r--r--classes/BusinessAdmin.class.php12
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
+}