Esempio n. 1
0
 public function generateQuery(Finder $finder)
 {
     foreach (FinderIterator::recursive($finder) as $f) {
         $f->setName(static::decamelize($f->getName()));
     }
     return $this->decorated->generateQuery($finder);
 }
Esempio n. 2
0
 protected function fetchMulti(Finder $finder, PDOStatement $statement)
 {
     $entityInstance = null;
     $finders = FinderIterator::recursive($finder);
     $row = $statement->fetch(PDO::FETCH_NUM);
     if (!$row) {
         return false;
     }
     $entities = new SplObjectStorage();
     foreach ($row as $n => $value) {
         $meta = $statement->getColumnMeta($n);
         if ('id' === $meta['name']) {
             if (0 !== $n) {
                 $entities[$entityInstance] = array('name' => $entityName, 'table_name' => $entityName, 'id' => $entityInstance->id, 'cols' => $this->extractColumns($entityInstance, $entityName));
             }
             $finders->next();
             $entityName = $finders->current()->getName();
             $entityInstance = new stdClass();
         }
         $entityInstance->{$meta['name']} = $value;
     }
     if (!empty($entities)) {
         $entities[$entityInstance] = array('name' => $entityName, 'table_name' => $entityName, 'id' => $entityInstance->id, 'cols' => $this->extractColumns($entityInstance, $entityName));
     }
     foreach ($entities as $instance) {
         foreach ($instance as $field => &$v) {
             if (strlen($field) - 3 === strripos($field, '_id')) {
                 foreach ($entities as $sub) {
                     if ($entities[$sub]['name'] === substr($field, 0, -3) && $sub->id === $v) {
                         $v = $sub;
                     }
                 }
             }
         }
     }
     return $entities;
 }