Exemplo n.º 1
0
 /**
  *
  */
 public function findAll(\Gacela\DataSource\Query\Query $query, \Gacela\DataSource\Resource $resource, array $inherits, array $dependents)
 {
     if (!count($query->from) > 0) {
         $query->from($resource->getName(), array_keys($resource->getFields()));
     }
     return $this->query($resource, $query);
 }
Exemplo n.º 2
0
 /**
  * @param \Gacela\DataSource\Resource $resource
  * @param \stdClass $data
  * @return bool
  */
 protected function _deleteRecord(\Gacela\DataSource\Resource $resource, array $data)
 {
     $primary = $this->_primaryKey($resource->getPrimaryKey(), $data);
     if (is_null($primary)) {
         return true;
     }
     $where = $this->_gacela()->autoload('Criteria');
     $where = new $where();
     foreach ($primary as $key => $value) {
         $where->equals($key, $value);
     }
     return $this->_source()->delete($resource->getName(), $this->_source()->getQuery($where));
 }
Exemplo n.º 3
0
 /**
  * @param array $primary
  * @param Resource $resource
  * @param array $inherits
  * @param array $dependents
  * @return
  */
 public function find(array $primary, \Gacela\DataSource\Resource $resource, array $inherits = array(), array $dependents = array())
 {
     $crit = new \Gacela\Criteria();
     foreach ($primary as $key => $val) {
         $crit->equals($resource->getName() . '.' . $key, $val);
     }
     return $this->query($resource, $this->_buildFinder($this->getQuery($crit), $resource, $inherits, $dependents))->fetchObject();
 }