Esempio n. 1
0
 public function getLastEntry($scope)
 {
     $query = new Query($this->getNamespace('Log') . '\\Model\\Log', 'read');
     $query->select('*')->from('log')->limit(1);
     $query->where('scope = :scope');
     $query->bind(':scope', $scope);
     $query->order('id', 'DESC');
     try {
         $query->execute();
         return $query->fetch();
     } catch (PDOException $ex) {
         throw new StoreException('Could not get Log by Id', 0, $ex);
     }
 }
Esempio n. 2
0
 /**
  * @param $value
  * @param string $useConnection Connection type to use.
  * @throws StoreException
  * @return Contact
  */
 public function getByEmail($value, $useConnection = 'read')
 {
     if (is_null($value)) {
         throw new StoreException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
     }
     $query = new Query($this->getNamespace('Contact') . '\\Model\\Contact', $useConnection);
     $query->select('*')->from('contact')->limit(1);
     $query->where('`email` = :email');
     $query->bind(':email', $value);
     try {
         $query->execute();
         $result = $query->fetch();
         $this->setCache($value, $result);
         return $result;
     } catch (PDOException $ex) {
         throw new StoreException('Could not get Contact by Email', 0, $ex);
     }
 }
Esempio n. 3
0
 /**
  * @param $value
  * @param string $useConnection Connection type to use.
  * @throws StoreException
  * @return ContentItem
  */
 public function getById($value, $useConnection = 'read')
 {
     if (is_null($value)) {
         throw new StoreException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
     }
     // This is the primary key, so try and get from cache:
     $cacheResult = $this->getFromCache($value);
     if (!empty($cacheResult)) {
         return $cacheResult;
     }
     $query = new Query($this->getNamespace('ContentItem') . '\\Model\\ContentItem', $useConnection);
     $query->select('*')->from('content_item')->limit(1);
     $query->where('`id` = :id');
     $query->bind(':id', $value);
     try {
         $query->execute();
         $result = $query->fetch();
         $this->setCache($value, $result);
         return $result;
     } catch (PDOException $ex) {
         throw new StoreException('Could not get ContentItem by Id', 0, $ex);
     }
 }
Esempio n. 4
0
 /**
  * @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);
     }
 }
Esempio n. 5
0
 /**
  * @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);
     }
 }
Esempio n. 6
0
 /**
  * @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);
     }
 }
Esempio n. 7
0
 /**
  * @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);
     }
 }