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\Sqlsrv
;
13 use Zend\Db\Adapter\Driver\ResultInterface
;
15 class Result
implements Iterator
, ResultInterface
21 protected $resource = null;
26 protected $currentData = false;
32 protected $currentComplete = false;
38 protected $position = -1;
43 protected $generatedValue = null;
48 * @param resource $resource
49 * @param mixed $generatedValue
52 public function initialize($resource, $generatedValue = null)
54 $this->resource = $resource;
55 $this->generatedValue
= $generatedValue;
62 public function buffer()
70 public function isBuffered()
80 public function getResource()
82 return $this->resource;
90 public function current()
92 if ($this->currentComplete
) {
93 return $this->currentData
;
97 return $this->currentData
;
105 public function next()
117 protected function load($row = SQLSRV_SCROLL_NEXT
)
119 $this->currentData
= sqlsrv_fetch_array($this->resource, SQLSRV_FETCH_ASSOC
, $row);
120 $this->currentComplete
= true;
122 return $this->currentData
;
130 public function key()
132 return $this->position
;
140 public function rewind()
143 $this->load(SQLSRV_SCROLL_FIRST
);
152 public function valid()
154 if ($this->currentComplete
&& $this->currentData
) {
158 return $this->load();
166 public function count()
168 return sqlsrv_num_rows($this->resource);
174 public function getFieldCount()
176 return sqlsrv_num_fields($this->resource);
184 public function isQueryResult()
186 if (is_bool($this->resource)) {
189 return (sqlsrv_num_fields($this->resource) > 0);
197 public function getAffectedRows()
199 return sqlsrv_rows_affected($this->resource);
205 public function getGeneratedValue()
207 return $this->generatedValue
;