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\IbmDb2
;
12 use Zend\Db\Adapter\Driver\ResultInterface
;
13 use Zend\Db\Adapter\Exception
;
15 class Result
implements ResultInterface
25 protected $position = 0;
30 protected $currentComplete = false;
35 protected $currentData = null;
40 protected $generatedValue = null;
43 * @param resource $resource
44 * @param mixed $generatedValue
47 public function initialize($resource, $generatedValue = null)
49 $this->resource = $resource;
50 $this->generatedValue
= $generatedValue;
55 * (PHP 5 >= 5.0.0)<br/>
56 * Return the current element
57 * @link http://php.net/manual/en/iterator.current.php
58 * @return mixed Can return any type.
60 public function current()
62 if ($this->currentComplete
) {
63 return $this->currentData
;
66 $this->currentData
= db2_fetch_assoc($this->resource);
67 return $this->currentData
;
73 public function next()
75 $this->currentData
= db2_fetch_assoc($this->resource);
76 $this->currentComplete
= true;
78 return $this->currentData
;
86 return $this->position
;
92 public function valid()
94 return ($this->currentData
!== false);
98 * (PHP 5 >= 5.0.0)<br/>
99 * Rewind the Iterator to the first element
100 * @link http://php.net/manual/en/iterator.rewind.php
101 * @return void Any returned value is ignored.
103 public function rewind()
105 if ($this->position
> 0) {
106 throw new Exception\
RuntimeException(
107 'This result is a forward only result set, calling rewind() after moving forward is not supported'
110 $this->currentData
= db2_fetch_assoc($this->resource);
111 $this->currentComplete
= true;
120 public function buffer()
126 * Check if is buffered
130 public function isBuffered()
140 public function isQueryResult()
142 return (db2_num_fields($this->resource) > 0);
150 public function getAffectedRows()
152 return db2_num_rows($this->resource);
156 * Get generated value
160 public function getGeneratedValue()
162 return $this->generatedValue
;
170 public function getResource()
172 return $this->resource;
180 public function getFieldCount()
182 return db2_num_fields($this->resource);
188 public function count()