本文整理汇总了PHP中Zend\Db\ResultSet\ResultSet::setDataSource方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultSet::setDataSource方法的具体用法?PHP ResultSet::setDataSource怎么用?PHP ResultSet::setDataSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\ResultSet\ResultSet
的用法示例。
在下文中一共展示了ResultSet::setDataSource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToArrayCreatesArrayOfArraysRepresentingRows
public function testToArrayCreatesArrayOfArraysRepresentingRows()
{
$count = rand(3, 75);
$dataSource = $this->getArrayDataSource($count);
$this->set->setDataSource($dataSource);
$test = $this->set->toArray();
$this->assertEquals($dataSource->getArrayCopy(), $test, var_export($test, 1));
}
示例2: fetchAll
public function fetchAll()
{
$statement = $dbAdapter->createStatement();
$select->prepareStatement($dbAdapter, $statement);
$driverResult = $statment->execute();
$resultset = new ResultSet();
$resultset->setDataSource($driverResult);
foreach ($resultset as $row) {
// $row is an ArrayObject
}
}
示例3: fetchAll
public function fetchAll()
{
$select = new Select();
$select->from('person')->columns(array('f_name' => 'person.firstname', 'l_name' => 'person.lastname', 'comp_name' => 'contact.companyname', 'cont_name' => 'contactstate.name'))->join('contact', 'contactstate', 'person.id = contact.person_id', 'contact.state_contactstate_id = contactstate.id');
$statement = $dbAdapter->createStatement();
$select->prepareStatement($dbAdapter, $statement);
$driverResult = $statment->execute();
$resultset = new ResultSet();
$resultset->setDataSource($driverResult);
foreach ($resultset as $row) {
// $row is an ArrayObject
}
}
示例4: selectWith
public function selectWith(Select $select, $scrollable = true)
{
// Get the data
$adapter = $this->getReadAdapter();
$statement = $adapter->createStatement();
$select->prepareStatement($adapter, $statement);
$result = $statement->execute();
if ($scrollable) {
// Convert data to an array so we can iterate more than once
$resultArray = array();
foreach ($result as $row) {
$resultArray[] = $this->toScalarValueArray($row);
}
$result = $resultArray;
}
// Create the ResultSet
$resultSet = new ResultSet();
$resultSet->setRowObjectPrototype($this->getModelPrototype());
$resultSet->setDataSource($result);
return $resultSet;
}
示例5: _authenticateQuerySelect
/**
* _authenticateQuerySelect() - This method accepts a Zend\Db\Sql\Select object and
* performs a query against the database with that object.
*
* @param DbSelect $dbSelect
* @throws Exception\RuntimeException when an invalid select object is encountered
* @return array
*/
protected function _authenticateQuerySelect(DbSelect $dbSelect)
{
$statement = $this->_zendDb->createStatement();
$dbSelect->prepareStatement($this->_zendDb, $statement);
$resultSet = new ResultSet();
try {
$resultSet->setDataSource($statement->execute(array($this->_credential, $this->_identity)));
$resultIdentities = $resultSet->toArray();
} catch (\Exception $e) {
throw new Exception\RuntimeException(
'The supplied parameters to DbTable failed to '
. 'produce a valid sql statement, please check table and column names '
. 'for validity.', 0, $e
);
}
return $resultIdentities;
}