3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Db\Adapter\Driver\Pgsql
;
12 use Zend\Db\Adapter\Driver\ResultInterface
;
13 use Zend\Db\Adapter\Exception
;
15 class Result
implements ResultInterface
21 protected $resource = null;
26 protected $position = 0;
36 protected $generatedValue = null;
42 * @param $generatedValue
44 * @throws Exception\InvalidArgumentException
46 public function initialize($resource, $generatedValue)
48 if (!is_resource($resource) ||
get_resource_type($resource) != 'pgsql result') {
49 throw new Exception\
InvalidArgumentException('Resource not of the correct type.');
52 $this->resource = $resource;
53 $this->count
= pg_num_rows($this->resource);
54 $this->generatedValue
= $generatedValue;
60 * @return array|bool|mixed
62 public function current()
64 if ($this->count
=== 0) {
67 return pg_fetch_assoc($this->resource, $this->position
);
75 public function next()
87 return $this->position
;
95 public function valid()
97 return ($this->position
< $this->count
);
105 public function rewind()
115 public function buffer()
125 public function isBuffered()
135 public function isQueryResult()
137 return (pg_num_fields($this->resource) > 0);
145 public function getAffectedRows()
147 return pg_affected_rows($this->resource);
151 * Get generated value
155 public function getGeneratedValue()
157 return $this->generatedValue
;
163 public function getResource()
165 // TODO: Implement getResource() method.
171 * (PHP 5 >= 5.1.0)<br/>
172 * Count elements of an object
173 * @link http://php.net/manual/en/countable.count.php
174 * @return int The custom count as an integer.
177 * The return value is cast to an integer.
179 public function count()
189 public function getFieldCount()
191 return pg_num_fields($this->resource);