Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Db / Adapter / Driver / Pgsql / Result.php
blobb007bc4a7c4ccc483af2a6a423aa995f753ba659
1 <?php
2 /**
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
8 */
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
18 /**
19 * @var resource
21 protected $resource = null;
23 /**
24 * @var int
26 protected $position = 0;
28 /**
29 * @var int
31 protected $count = 0;
33 /**
34 * @var null|mixed
36 protected $generatedValue = null;
38 /**
39 * Initialize
41 * @param $resource
42 * @param $generatedValue
43 * @return void
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;
57 /**
58 * Current
60 * @return array|bool|mixed
62 public function current()
64 if ($this->count === 0) {
65 return false;
67 return pg_fetch_assoc($this->resource, $this->position);
70 /**
71 * Next
73 * @return void
75 public function next()
77 $this->position++;
80 /**
81 * Key
83 * @return int|mixed
85 public function key()
87 return $this->position;
90 /**
91 * Valid
93 * @return bool
95 public function valid()
97 return ($this->position < $this->count);
101 * Rewind
103 * @return void
105 public function rewind()
107 $this->position = 0;
111 * Buffer
113 * @return null
115 public function buffer()
117 return null;
121 * Is buffered
123 * @return false
125 public function isBuffered()
127 return false;
131 * Is query result
133 * @return bool
135 public function isQueryResult()
137 return (pg_num_fields($this->resource) > 0);
141 * Get affected rows
143 * @return int
145 public function getAffectedRows()
147 return pg_affected_rows($this->resource);
151 * Get generated value
153 * @return mixed|null
155 public function getGeneratedValue()
157 return $this->generatedValue;
161 * Get resource
163 public function getResource()
165 // TODO: Implement getResource() method.
169 * Count
171 * (PHP 5 &gt;= 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.
175 * </p>
176 * <p>
177 * The return value is cast to an integer.
179 public function count()
181 return $this->count;
185 * Get field count
187 * @return int
189 public function getFieldCount()
191 return pg_num_fields($this->resource);