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 / Sqlsrv / Result.php
blob77a22d8fdb0753c0b3910021b6e9e04253313504
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\Sqlsrv;
12 use Iterator;
13 use Zend\Db\Adapter\Driver\ResultInterface;
15 class Result implements Iterator, ResultInterface
18 /**
19 * @var resource
21 protected $resource = null;
23 /**
24 * @var bool
26 protected $currentData = false;
28 /**
30 * @var bool
32 protected $currentComplete = false;
34 /**
36 * @var int
38 protected $position = -1;
40 /**
41 * @var mixed
43 protected $generatedValue = null;
45 /**
46 * Initialize
48 * @param resource $resource
49 * @param mixed $generatedValue
50 * @return Result
52 public function initialize($resource, $generatedValue = null)
54 $this->resource = $resource;
55 $this->generatedValue = $generatedValue;
56 return $this;
59 /**
60 * @return null
62 public function buffer()
64 return null;
67 /**
68 * @return bool
70 public function isBuffered()
72 return false;
75 /**
76 * Get resource
78 * @return resource
80 public function getResource()
82 return $this->resource;
85 /**
86 * Current
88 * @return mixed
90 public function current()
92 if ($this->currentComplete) {
93 return $this->currentData;
96 $this->load();
97 return $this->currentData;
101 * Next
103 * @return bool
105 public function next()
107 $this->load();
108 return true;
112 * Load
114 * @param int $row
115 * @return mixed
117 protected function load($row = SQLSRV_SCROLL_NEXT)
119 $this->currentData = sqlsrv_fetch_array($this->resource, SQLSRV_FETCH_ASSOC, $row);
120 $this->currentComplete = true;
121 $this->position++;
122 return $this->currentData;
126 * Key
128 * @return mixed
130 public function key()
132 return $this->position;
136 * Rewind
138 * @return bool
140 public function rewind()
142 $this->position = 0;
143 $this->load(SQLSRV_SCROLL_FIRST);
144 return true;
148 * Valid
150 * @return bool
152 public function valid()
154 if ($this->currentComplete && $this->currentData) {
155 return true;
158 return $this->load();
162 * Count
164 * @return int
166 public function count()
168 return sqlsrv_num_rows($this->resource);
172 * @return bool|int
174 public function getFieldCount()
176 return sqlsrv_num_fields($this->resource);
180 * Is query result
182 * @return bool
184 public function isQueryResult()
186 if (is_bool($this->resource)) {
187 return false;
189 return (sqlsrv_num_fields($this->resource) > 0);
193 * Get affected rows
195 * @return int
197 public function getAffectedRows()
199 return sqlsrv_rows_affected($this->resource);
203 * @return mixed|null
205 public function getGeneratedValue()
207 return $this->generatedValue;