/** * 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); } }
/** * @param $value * @param array $options Limits, offsets, etc. * @param string $useConnection Connection type to use. * @throws StoreException * @return SystemJob[] */ public function getByRunDate($value, $options = [], $useConnection = 'read') { if (is_null($value)) { throw new StoreException('Value passed to ' . __FUNCTION__ . ' cannot be null.'); } $query = new Query($this->getNamespace('SystemJob') . '\\Model\\SystemJob', $useConnection); $query->from('system_job')->where('`run_date` = :run_date'); $query->bind(':run_date', $value); $this->handleQueryOptions($query, $options); try { $query->execute(); return $query->fetchAll(); } catch (PDOException $ex) { throw new StoreException('Could not get SystemJob by RunDate', 0, $ex); } }
/** * @param $value * @param array $options Limits, offsets, etc. * @param string $useConnection Connection type to use. * @throws StoreException * @return PermissionCollection */ public function getByUserId($value, $options = [], $useConnection = 'read') { if (is_null($value)) { throw new StoreException('Value passed to ' . __FUNCTION__ . ' cannot be null.'); } $query = new Query($this->getNamespace('Permission') . '\\Model\\Permission', $useConnection); $query->from('permission')->where('`user_id` = :user_id'); $query->bind(':user_id', $value); $this->handleQueryOptions($query, $options); try { $query->execute(); return new PermissionCollection($query->fetchAll()); } catch (PDOException $ex) { throw new StoreException('Could not get Permission by UserId', 0, $ex); } }
/** * @param $value * @param array $options Limits, offsets, etc. * @param string $useConnection Connection type to use. * @throws StoreException * @return SettingCollection */ public function getByScope($value, $options = [], $useConnection = 'read') { if (is_null($value)) { throw new StoreException('Value passed to ' . __FUNCTION__ . ' cannot be null.'); } $query = new Query($this->getNamespace('Setting') . '\\Model\\Setting', $useConnection); $query->from('setting')->where('`scope` = :scope'); $query->bind(':scope', $value); $this->handleQueryOptions($query, $options); try { $query->execute(); return new SettingCollection($query->fetchAll()); } catch (PDOException $ex) { throw new StoreException('Could not get Setting by Scope', 0, $ex); } }
/** * @param $value * @param array $options Limits, offsets, etc. * @param string $useConnection Connection type to use. * @throws StoreException * @return ScheduledJobCollection */ public function getByCurrentJobId($value, $options = [], $useConnection = 'read') { if (is_null($value)) { throw new StoreException('Value passed to ' . __FUNCTION__ . ' cannot be null.'); } $query = new Query($this->getNamespace('ScheduledJob') . '\\Model\\ScheduledJob', $useConnection); $query->from('scheduled_job')->where('`current_job_id` = :current_job_id'); $query->bind(':current_job_id', $value); $this->handleQueryOptions($query, $options); try { $query->execute(); return new ScheduledJobCollection($query->fetchAll()); } catch (PDOException $ex) { throw new StoreException('Could not get ScheduledJob by CurrentJobId', 0, $ex); } }