Source of file Result.php
Size: 3,787 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Db/Adapter/Driver/IbmDb2/Result.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Db\Adapter\Driver\IbmDb2; use Zend\Db\Adapter\Driver\ResultInterface; use Zend\Db\Adapter\Exception; class Result implements ResultInterface { /** * @var resource */ protected $resource; /** * @var int */ protected $position = 0; /** * @var bool */ protected $currentComplete = false; /** * @var mixed */ protected $currentData = null; /** * @var mixed */ protected $generatedValue = null; /** * @param resource $resource * @param mixed $generatedValue * @return Result */ public function initialize($resource, $generatedValue = null) { $this->resource = $resource; $this->generatedValue = $generatedValue; return $this; } /** * (PHP 5 >= 5.0.0)<br/> * Return the current element * @link http://php.net/manual/en/iterator.current.php * @return mixed Can return any type. */ public function current() { if ($this->currentComplete) { return $this->currentData; } $this->currentData = db2_fetch_assoc($this->resource); return $this->currentData; } /** * @return mixed */ public function next() { $this->currentData = db2_fetch_assoc($this->resource); $this->currentComplete = true; $this->position++; return $this->currentData; } /** * @return int|string */ public function key() { return $this->position; } /** * @return bool */ public function valid() { return ($this->currentData !== false); } /** * (PHP 5 >= 5.0.0)<br/> * Rewind the Iterator to the first element * @link http://php.net/manual/en/iterator.rewind.php * @return void Any returned value is ignored. */ public function rewind() { if ($this->position > 0) { throw new Exception\RuntimeException( 'This result is a forward only result set, calling rewind() after moving forward is not supported' ); } $this->currentData = db2_fetch_assoc($this->resource); $this->currentComplete = true; $this->position = 1; } /** * Force buffering * * @return void */ public function buffer() { return null; } /** * Check if is buffered * * @return bool|null */ public function isBuffered() { return false; } /** * Is query result? * * @return bool */ public function isQueryResult() { return (db2_num_fields($this->resource) > 0); } /** * Get affected rows * * @return int */ public function getAffectedRows() { return db2_num_rows($this->resource); } /** * Get generated value * * @return mixed|null */ public function getGeneratedValue() { return $this->generatedValue; } /** * Get the resource * * @return mixed */ public function getResource() { return $this->resource; } /** * Get field count * * @return int */ public function getFieldCount() { return db2_num_fields($this->resource); } /** * @return null|int */ public function count() { return null; } } |