本文整理汇总了PHP中Zend\Db\ResultSet\HydratingResultSet::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP HydratingResultSet::initialize方法的具体用法?PHP HydratingResultSet::initialize怎么用?PHP HydratingResultSet::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\ResultSet\HydratingResultSet
的用法示例。
在下文中一共展示了HydratingResultSet::initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToArray
/**
* @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);
}
示例2: getPagesList
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;
}
示例3: testCurrentWillReturnBufferedRow
/**
* @covers Zend\Db\ResultSet\HydratingResultSet::current
*/
public function testCurrentWillReturnBufferedRow()
{
$hydratingRs = new HydratingResultSet();
$hydratingRs->initialize(new \ArrayIterator(array(array('id' => 1, 'name' => 'one'), array('id' => 2, 'name' => 'two'))));
$hydratingRs->buffer();
$obj1 = $hydratingRs->current();
$hydratingRs->rewind();
$obj2 = $hydratingRs->current();
$this->assertSame($obj1, $obj2);
}
示例4: fetchAll
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;
}
示例5: contohGetList
/**
* @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);
}
示例6: findActive
/**
* @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 [];
}
示例7: findAll
/**
* {@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 [];
}
示例8: findAll
/**
* {@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();
}
示例9: getUsersList
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();
}
示例10: fetchAll
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;
}
示例11: fetchAll
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;
}
示例12: fetch
/**
* 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;
}
示例13: fetchAll
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;
}
示例14: getAttributes
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;
}
示例15: findById
/**
* @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;
}