private static function loadDataBase() { if (empty(self::$db)) { self::$db = SQLite::Instance(self::DB); } }
public static function MonthsAvailable($year = NULL) { $months = array(); if (is_null($year)) { $year = date('Y'); } $db = SQLite::Instance(); $query = $db->prepare("SELECT DISTINCT strftime('%m', timestamp, 'unixepoch', 'localtime') AS month FROM mood WHERE strftime('%Y', timestamp, 'unixepoch', 'localtime') = :year ORDER BY month DESC"); $query->execute(array('year' => $year)); while ($data = $query->fetch()) { $months[] = $data['month']; } $query->closeCursor(); return $months; }
public static function getUsers() { $q = SQLite::Instance(self::DB)->query('SELECT id, email, last_login FROM users ORDER BY id ASC'); $result = $q->fetchAll(); $q->closeCursor(); return $result; }
public static function getApis() { $query = SQLite::Instance(self::DB)->query('SELECT id, api_name, last_timestamp, last_ip, count FROM credentials'); $data = $query->fetchAll(); $query->closeCursor(); return $data; }
public static function countPendingRequests() { $query = SQLite::Instance(self::DB)->prepare('SELECT count(id) AS count FROM api_request WHERE approbation = :pending'); $query->execute(array('pending' => self::PENDING)); $data = $query->fetch(); $query->closeCursor(); return $data['count']; }
public function __construct() { $this->db = SQLite::Instance(self::DB_API); }