/**
  * @covers Zend\Db\ResultSet\HydratingResultSet::toArray
  * @todo   Implement testToArray().
  */
 public function testToArray()
 {
     $hydratingRs = new HydratingResultSet();
     $hydratingRs->initialize(array(array('id' => 1, 'name' => 'one')));
     $obj = $hydratingRs->toArray();
     $this->assertInternalType('array', $obj);
 }
Exemple #2
0
 public function getPagesList()
 {
     $stmt = $this->_dbAdapter->createStatement();
     $stmt->prepare('CALL `pages/get_slist`()');
     $result = $stmt->execute();
     $resultSet = new HydratingResultSet(new Reflection(), new Page());
     $resultSet->initialize($result);
     return $resultSet;
 }
Exemple #3
0
 public function __construct($table, Adapter $db, $strategies = array())
 {
     $hydrator = new ArraySerializable();
     foreach ($strategies as $field => $strategy) {
         $hydrator->addStrategy($field, $strategy);
     }
     $resultSet = new HydratingResultSet();
     $resultSet->setHydrator($hydrator);
     parent::__construct($table, $db, null, $resultSet);
 }
 /**
  * gets the resultSet
  *
  * @return HydratingResultSet
  */
 protected function getResultSet()
 {
     if (!$this->resultSetPrototype instanceof HydratingResultSet) {
         $resultSetPrototype = new HydratingResultSet();
         $resultSetPrototype->setHydrator($this->getHydrator());
         $resultSetPrototype->setObjectPrototype($this->getModel());
         $this->resultSetPrototype = $resultSetPrototype;
     }
     return clone $this->resultSetPrototype;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $db = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new HydratingResultSet();
     $resultSetPrototype->setHydrator(new ObjectProperty());
     $resultSetPrototype->setObjectPrototype(new ForgotPassword());
     $tableGateway = new TableGateway('vc_forget_tokens', $db, array(), $resultSetPrototype);
     $table = new ForgotPasswordTable($tableGateway);
     return $table;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $db = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new HydratingResultSet();
     $resultSetPrototype->setHydrator(new ObjectProperty());
     $resultSetPrototype->setObjectPrototype(new Resource());
     $tableGateway = new TableGateway('resource', $db, null, $resultSetPrototype);
     $table = new ResourceTable($tableGateway);
     return $table;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $db = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new HydratingResultSet();
     $resultSetPrototype->setHydrator(new ObjectProperty());
     $resultSetPrototype->setObjectPrototype(new ViewProfileCount());
     $tableGateway = new TableGateway('vc_view_profiles_count', $db, array(), $resultSetPrototype);
     $table = new ViewProfileCountTable($tableGateway);
     return $table;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $db = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new HydratingResultSet();
     $resultSetPrototype->setHydrator(new ObjectProperty());
     $resultSetPrototype->setObjectPrototype(new SearchCategoriesList());
     $tableGateway = new TableGateway('search_categories_list', $db, array(), $resultSetPrototype);
     $table = new SearchCategoriesListTable($tableGateway);
     return $table;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $db = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new HydratingResultSet();
     $resultSetPrototype->setHydrator(new ObjectProperty());
     $resultSetPrototype->setObjectPrototype(new SettingFlexibleType());
     $tableGateway = new TableGateway('setting_flexible_type', $db, array(), $resultSetPrototype);
     $table = new SettingFlexibleTypeTable($tableGateway);
     return $table;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $db = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new HydratingResultSet();
     $resultSetPrototype->setHydrator(new ObjectProperty());
     $resultSetPrototype->setObjectPrototype(new LoginLinkExpired());
     $tableGateway = new TableGateway('login_link_expired', $db, array(), $resultSetPrototype);
     $table = new LoginLinkExpiredTable($tableGateway);
     return $table;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $db = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new HydratingResultSet();
     $resultSetPrototype->setHydrator(new ObjectProperty());
     $resultSetPrototype->setObjectPrototype(new JsPlumbGrid());
     $tableGateway = new TableGateway('js_plumb_grid', $db, array(), $resultSetPrototype);
     $table = new JsPlumbGridTable($tableGateway);
     return $table;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $db = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new HydratingResultSet();
     $resultSetPrototype->setHydrator(new ObjectProperty());
     $resultSetPrototype->setObjectPrototype(new UserSkills());
     $tableGateway = new TableGateway('vc_user_skills', $db, array(), $resultSetPrototype);
     $table = new UserSkillsTable($tableGateway);
     return $table;
 }
Exemple #13
0
 /**
  * @return Route[]
  */
 public function findActive()
 {
     $sql = new Sql($this->dbAdapter);
     $select = $sql->select($this->table)->where('active = 1');
     $result = $sql->prepareStatementForSqlObject($select)->execute();
     if ($result->isQueryResult() && $result->getAffectedRows()) {
         $resultSet = new HydratingResultSet($this->hydrator, $this->model);
         return $resultSet->initialize($result);
     }
     return [];
 }
Exemple #14
0
 /**
  * @return JsonModel
  */
 public function contohGetList()
 {
     $sm = $this->getServiceLocator();
     $table = $sm->get('Organisasi\\DbTable\\StrukturOrganisasi');
     // defined in module.php
     $result = $table->select()->toArray();
     $resultSet = new HydratingResultSet(new ReflectionHydrator(), new StrukturOrganisasi());
     $resultSet->initialize($result);
     $a = array('data' => $result);
     return new JsonModel($a);
 }
Exemple #15
0
 public function fetchAll()
 {
     $select = $this->sql->select();
     $stmt = $this->sql->prepareStatementForSqlObject($select);
     $results = $stmt->execute();
     $entity = new ImpostoEntity();
     $classMethods = new ClassMethods();
     $resultset = new HydratingResultSet($classMethods, $entity);
     $resultset->initialize($results);
     return $resultset;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $db = $serviceLocator->get('Zend\\Db\\Adapter');
     $entity = new User();
     $set = new HydratingResultSet();
     $set->setObjectPrototype($entity);
     $set->setHydrator(new ClassMethods());
     $tableGateway = new TableGateway('User', $db, null, $set);
     $mapper = new UserMapper($tableGateway);
     return $mapper;
 }
Exemple #17
0
 public function fetchAll($filter)
 {
     $select = new Select('album');
     if (isset($filter['title'])) {
         $select->where(array('title LIKE ?' => '%' . $filter['title'] . '%'));
     }
     $resultset = new HydratingResultSet();
     $resultset->setObjectPrototype(new AlbumEntity());
     $paginatorAdapter = new DbSelect($select, $this->adapterSlave, $resultset);
     $collection = new AlbumCollection($paginatorAdapter);
     return $collection;
 }
Exemple #18
0
 /**
  * {@inheritDoc}
  */
 public function findAll()
 {
     $sql = new Sql($this->dbAdapter);
     $select = $sql->select('posts');
     $stmt = $sql->prepareStatementForSqlObject($select);
     $result = $stmt->execute();
     if ($result instanceof ResultInterface && $result->isQueryResult()) {
         $resultSet = new HydratingResultSet($this->hydrator, $this->postPrototype);
         return $resultSet->initialize($result);
     }
     return array();
 }
 public function fetchAll()
 {
     $select = $this->sql->select();
     $select->order(array('user ASC', 'name ASC'));
     $statement = $this->sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     $entityPrototype = new BuildingEntity();
     $hydrator = new ClassMethods();
     $resultset = new HydratingResultSet($hydrator, $entityPrototype);
     $resultset->initialize($results);
     return $resultset;
 }
 public function getUsersList()
 {
     $sql = new Sql($this->getAdaptor());
     $select = $sql->select('user');
     $statement = $sql->prepareStatementForSqlObject($select);
     $result = $statement->execute();
     if ($result instanceof ResultInterface && $result->isQueryResult()) {
         $resultSet = new HydratingResultSet($this->getHydrator(), $this->getProtoType());
         return $resultSet->initialize($result);
     }
     return array();
 }
 /**
  * {@inheritdoc}
  */
 public function findAll()
 {
     $sql = new Sql($this->dbAdapter);
     $select = $sql->select('posts');
     $stmt = $sql->prepareStatementForSqlObject($select);
     $result = $stmt->execute();
     if ($result instanceof ResultInterface && $result->isQueryResult()) {
         $resultSet = new HydratingResultSet(new ClassMethods(), new Post());
         return $resultSet->initialize($result);
     }
     return [];
 }
Exemple #22
0
 /**
  * Fetches rooms.
  * @return Zend\Db\ResultSet\HydratingResultSet collection of Room obj's
  */
 public function fetch()
 {
     $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $sql = new Sql($adapter);
     $select = $sql->select('room')->offset($this->offset)->limit($this->limit);
     $statement = $sql->prepareStatementForSqlObject($select);
     $res = $statement->execute();
     $resultSet = new HydratingResultSet(new hydrator(), new Room());
     if ($res instanceof ResultInterface && $res->isQueryResult()) {
         $resultSet->initialize($res);
     }
     return $resultSet;
 }
Exemple #23
0
 public function fetchAll($limit = 3)
 {
     $select = $this->sql->select();
     $select->order("date DESC");
     $select->limit($limit);
     $statement = $this->sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     $entityPrototype = new TumblrEntity();
     $hydrator = new ClassMethods();
     $resultset = new HydratingResultSet($hydrator, $entityPrototype);
     $resultset->initialize($results);
     return $resultset;
 }
 public function fetchAll($blvdId)
 {
     $select = $this->sql->select();
     $select->where(array("blvd_id" => $blvdId));
     $statement = $this->sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     $entityPrototype = new BlvdCategoryEntity();
     $hydrator = new ClassMethods();
     $resultset = new HydratingResultSet($hydrator, $entityPrototype);
     $resultset->initialize($results);
     $resultset->buffer();
     return $resultset;
 }
 /**
  * @param $postId int
  *
  * @return Post|null
  */
 public function findById($postId)
 {
     $sql = new \Zend\Db\Sql\Sql($this->adapter);
     $select = $sql->select();
     $select->columns(array('id', 'title', 'slug', 'content', 'created'))->from(array('p' => 'news'))->join(array('c' => 'category'), 'c.id = p.category_id', array('category_id' => 'id', 'name', 'category_slug' => 'slug'), $select::JOIN_INNER)->where(array('p.id' => $postId));
     $statement = $sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     $hydrator = new AggregateHydrator();
     $hydrator->add(new PostHydrator());
     $hydrator->add(new CategoryHydrator());
     $resultSet = new HydratingResultSet($hydrator, new Post());
     $resultSet->initialize($results);
     return $resultSet->count() > 0 ? $resultSet->current() : null;
 }
 public function getAttributes($id)
 {
     $select = $this->sql->select();
     $select->join('lead_attributes', 'lead_attribute_values.attribute_id = lead_attributes.id', array('attribute_name'));
     $select->where(array('entity_id' => $id));
     $select->order(array("id ASC"));
     $entityPrototype = new AttributeEntity();
     $hydrator = new ClassMethods();
     $resultset = new HydratingResultSet($hydrator, $entityPrototype);
     $statement = $this->sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     $resultset->initialize($results);
     return $resultset;
 }
 public function getPostList($page, $limit)
 {
     $sql = new Sql($this->getAdaptor());
     $select = $sql->select(array('p' => 'posts'));
     $select->join(array('u' => 'user'), 'p.author_id=u.user_id', array('author' => 'display_name'));
     $select->limit(intval($limit));
     $select->offset(intval($limit) * (intval($page) - 1));
     $statement = $sql->prepareStatementForSqlObject($select);
     $result = $statement->execute();
     if ($result instanceof ResultInterface && $result->isQueryResult()) {
         $resultSet = new HydratingResultSet($this->getHydrator(), $this->getProtoType());
         return $resultSet->initialize($result);
     }
     return array();
 }
Exemple #28
0
 /**
  * @return array|PostInterface[]
  */
 public function findAll()
 {
     $sql = new Sql($this->dbAdapter);
     $select = $sql->select('posts');
     $stmt = $sql->prepareStatementForSqlObject($select);
     $result = $stmt->execute();
     if ($result instanceof ResultInterface && $result->isQueryResult()) {
         //$resultSet = new ResultSet();
         //$resultSet = new HydratingResultSet(new \Zend\Stdlib\Hydrator\ClassMethods(), new \Blog\Model\Post());
         $resultSet = new HydratingResultSet($this->hydrator, $this->postPrototype);
         //    \Zend\Debug\Debug::dump($resultSet->initialize($result));die();
         return $resultSet->initialize($result);
     }
     return array();
 }
 /**
  * Fetches equipments of the room.
  * @see init()
  * @return \Zend\Db\ResultSet\HydratingResultSet of Equipment objects
  */
 public function fetch()
 {
     if (!$this->is_init()) {
         throw new \Exception("Equipments collection uninitiated.");
     }
     $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $sql = new Sql($adapter);
     $select = $sql->select('equipment')->where(array('cid' => $this->room->id))->offset($this->offset)->limit($this->limit);
     $statement = $sql->prepareStatementForSqlObject($select);
     $res = $statement->execute();
     $hydratedRes = new HydratingResultSet(new Hydrator(), new Equipment());
     if ($res instanceof ResultInterface && $res->isQueryResult()) {
         $hydratedRes->initialize($res);
     }
     return $hydratedRes;
 }
 public function fetchAll($paging = false, $sort = "timecreated", $order = "DESC", $filters = array())
 {
     $select = $this->sql->select();
     $select->order(array("{$sort} {$order}"));
     $where = array();
     if ($filters) {
         foreach ($filters as $filter => $condition) {
             if (strlen($condition)) {
                 switch ($filter) {
                     case 'timecreated':
                     case 'daterange':
                         list($from, $to) = array_map(function ($d, $i) {
                             $t = $i == 'from' ? '00:00:00' : '23:59:59';
                             return date('Y-m-d ' . $t, strtotime($d));
                         }, explode("-", $condition), ['from', 'to']);
                         $where[] = "lead.timecreated between '{$from}' and '{$to}'";
                         break;
                     case 'status':
                         $where[] = "lead.submitted = {$condition}";
                         break;
                     case 'sites':
                         $where[] = "lead.formid = {$condition}";
                         break;
                     default:
                         break;
                 }
             }
         }
         if ($where) {
             $select->where($where);
         }
     }
     $entityPrototype = new LeadEntity();
     $hydrator = new ClassMethods();
     if ($paging) {
         // create a new result set based on the Lead entity
         $resultSet = new HydratingResultSet($hydrator, $entityPrototype);
         $paginatorAdapter = new DbSelect($select, $this->dbAdapter, $resultSet);
         $paginator = new Paginator($paginatorAdapter);
         return $paginator;
     }
     $resultset = new HydratingResultSet($hydrator, $entityPrototype);
     $statement = $this->sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     $resultset->initialize($results);
     return $resultset;
 }