public function testCanProvideIteratorAggregateAsDataSource()
 {
     $iteratorAggregate = $this->getMock('IteratorAggregate', array('getIterator'), array(new SplStack()));
     $iteratorAggregate->expects($this->any())->method('getIterator')->will($this->returnValue($iteratorAggregate));
     $this->resultSet->initialize($iteratorAggregate);
     $this->assertSame($iteratorAggregate->getIterator(), $this->resultSet->getDataSource());
 }
Exemplo n.º 2
0
 /**
  * Fetch One
  *
  * @param mixed $query      (\Zend\Db\Sql\*|string) Query
  * @param mixed $parameters Parameters
  *
  * @return mixed
  */
 public function fetchOne($query, $parameters = null)
 {
     if ($query instanceof ResultSet) {
         $resultSet = $query;
     } else {
         $resultSet = new ResultSet();
         $resultSet->initialize($this->execute($query, $parameters));
     }
     $result = $resultSet->getDataSource()->getResource()->fetchColumn();
     $resultSet->getDataSource()->getResource()->closeCursor();
     return $result;
 }
 /**
  * @param Zend\Db\ResultSet
  */
 public static function getSqlForResult(ResultSet $result)
 {
     return $result->getDataSource()->getResource()->queryString;
 }
 /**
  * Get the data source used to create the result set
  *
  * @return null|Iterator
  */
 public function getDataSource()
 {
     return $this->zfResultSet->getDataSource();
 }