当前位置: 首页>>代码示例>>PHP>>正文


PHP ResultSet::setDataSource方法代码示例

本文整理汇总了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));
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:8,代码来源:ResultSetTest.php

示例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
     }
 }
开发者ID:BGCX262,项目名称:zurmo-b-2013-svn-to-git,代码行数:11,代码来源:OpportunityTable.php

示例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
     }
 }
开发者ID:BGCX262,项目名称:zurmo-b-2013-svn-to-git,代码行数:13,代码来源:LeadsTable.php

示例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;
 }
开发者ID:ashimidashajia,项目名称:zendstore,代码行数:21,代码来源:DbAdapterMapper.php

示例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;
 }
开发者ID:necrogami,项目名称:zf2,代码行数:25,代码来源:DbTable.php


注:本文中的Zend\Db\ResultSet\ResultSet::setDataSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。