/** $afterDateTime: The earliest date/time that the announcement(s) was created; null if no restriction $maxNumAnnouncements: The maximum number of announcements to return; null if no limit; $userID: The id of the user who created the announcement(s); null if no restriction */ public static function retrieveAnnouncements($afterDateTime = null, $maxNumAnnouncements = null, $userID = null) { $result = buildRetrieveSQL($afterDateTime, $maxNumAnnouncements, $userID); $strSQL = $result[0]; $parameters = $result[1]; $statement = DBConnection::executeSQLSelect($strSQL, $parameters); $announcements = array(); $i = 0; while ($row = $statement->fetch()) { $announcements[$i++] = self::convertRowToAnnouncement($row); } return $announcements; }
/** $where = 'WHERE [column_name]=:value' $value = what should replace ':value' in $where returns a User if the user is found or null otherwise */ private static function retrieveUserWhere($where, $value) { $connection = DBConnection::getConnection(); $sql = "SELECT id, username, password, name FROM Users WHERE {$where}"; $parameters[':value'] = $value; $statement = DBConnection::executeSQLSelect($sql, $parameters); $result = $statement->fetch(); if ($result === null) { return null; } else { $user = new User($result['id'], $result['username'], $result['password'], $result['name']); return $user; } }