當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。