public static function scanForItemWonNotifications() { $query = 'SELECT au.*, aumb.max_bid FROM Auction AS au JOIN AuctionsMaxBid AS aumb ON aumb.auction_id = au.id WHERE au.end_date < NOW() AND au.id NOT IN (SELECT auction_id FROM Notification WHERE type = ?)'; $results = Database::select($query, [NotificationType::itemWon()]); if (count($results)) { $auctions = Auction::arrayFromSQLRows($results); foreach ($auctions as $auction) { self::sendItemWonNotification($auction); } } }
public static function categoriesForItem($item_id) { $results = Database::select('SELECT * FROM Category WHERE id IN (SELECT category_id FROM ItemCategory WHERE item_id = ?)', [$item_id]); return self::arrayFromSQLRows($results); }
public function getReserve() { if ($this->reserve_price < 0) { $result = Database::select('SELECT reserve_price FROM Auction WHERE id = ?', [$this->id]); $this->reserve_price = $result[0][0]; } return $this->reserve_price; }
public static function forUser($user_id) { $results = Database::select('SELECT * FROM Notification WHERE user_id = ? AND cleared = 0', [$user_id]); return self::arrayFromSQLRows($results); }