Source of file Result.php
Size: 3,484 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Db/Adapter/Driver/Pgsql/Result.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 | <?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\Pgsql; use Zend\Db\Adapter\Driver\ResultInterface; use Zend\Db\Adapter\Exception; class Result implements ResultInterface { /** * @var resource */ protected $resource = null; /** * @var int */ protected $position = 0; /** * @var int */ protected $count = 0; /** * @var null|mixed */ protected $generatedValue = null; /** * Initialize * * @param $resource * @param $generatedValue * @return void * @throws Exception\InvalidArgumentException */ public function initialize($resource, $generatedValue) { if (!is_resource($resource) || get_resource_type($resource) != 'pgsql result') { throw new Exception\InvalidArgumentException('Resource not of the correct type.'); } $this->resource = $resource; $this->count = pg_num_rows($this->resource); $this->generatedValue = $generatedValue; } /** * Current * * @return array|bool|mixed */ public function current() { if ($this->count === 0) { return false; } return pg_fetch_assoc($this->resource, $this->position); } /** * Next * * @return void */ public function next() { $this->position++; } /** * Key * * @return int|mixed */ public function key() { return $this->position; } /** * Valid * * @return bool */ public function valid() { return ($this->position < $this->count); } /** * Rewind * * @return void */ public function rewind() { $this->position = 0; } /** * Buffer * * @return null */ public function buffer() { return null; } /** * Is buffered * * @return false */ public function isBuffered() { return false; } /** * Is query result * * @return bool */ public function isQueryResult() { return (pg_num_fields($this->resource) > 0); } /** * Get affected rows * * @return int */ public function getAffectedRows() { return pg_affected_rows($this->resource); } /** * Get generated value * * @return mixed|null */ public function getGeneratedValue() { return $this->generatedValue; } /** * Get resource */ public function getResource() { // TODO: Implement getResource() method. } /** * Count * * (PHP 5 >= 5.1.0)<br/> * Count elements of an object * @link http://php.net/manual/en/countable.count.php * @return int The custom count as an integer. * </p> * <p> * The return value is cast to an integer. */ public function count() { return $this->count; } /** * Get field count * * @return int */ public function getFieldCount() { return pg_num_fields($this->resource); } } |