/** * @return \b8\Model\Collection */ public function all() { $query = new Database\Query($this->modelName, 'read'); $query->select('*')->from($this->tableName)->execute(); $class = $this->modelName . 'Collection'; return new $class($query->fetchAll()); }
public function getTimeline() { $query = new Query($this->getNamespace('Log') . '\\Model\\Log', 'read'); $query->select('*')->from('log')->limit(100); $query->where('type IN (2, 4, 8, 128)'); $query->order('id', 'DESC'); try { $query->execute(); return $query->fetchAll(); } catch (PDOException $ex) { throw new StoreException('Could not get Log by Id', 0, $ex); } }
/** * Get jobs due to be scheduled. */ public function getJobsToSchedule() { $query = new Query($this->getNamespace('ScheduledJob') . '\\Model\\ScheduledJob', 'read'); $query->select('s.*'); $query->from('scheduled_job', 's'); $query->join('job', 'j', 's.current_job_id = j.id'); $query->where('(j.id IS NULL) OR ((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(j.date_updated)) >= s.frequency AND j.status > 1)'); try { $query->execute(); return new ScheduledJobCollection($query->fetchAll()); } catch (PDOException $ex) { throw new StoreException('Could not get ScheduledJob by CurrentJob', 0, $ex); } }
public function getList() { $query = new Database\Query('\\Octo\\System\\Model\\Contact', 'read'); $query->select('*')->from('contact')->order('first_name', 'ASC')->order('last_name', 'ASC')->execute(); return new Octo\System\Model\ContactCollection($query->fetchAll()); }