Source of file Result.php
Size: 3,608 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Db/Adapter/Driver/Sqlsrv/Result.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Db\Adapter\Driver\Sqlsrv; use Iterator; use Zend\Db\Adapter\Driver\ResultInterface; class Result implements Iterator, ResultInterface { /** * @var resource */ protected $resource = null; /** * @var bool */ protected $currentData = false; /** * * @var bool */ protected $currentComplete = false; /** * * @var int */ protected $position = -1; /** * @var mixed */ protected $generatedValue = null; /** * Initialize * * @param resource $resource * @param mixed $generatedValue * @return Result */ public function initialize($resource, $generatedValue = null) { $this->resource = $resource; $this->generatedValue = $generatedValue; return $this; } /** * @return null */ public function buffer() { return null; } /** * @return bool */ public function isBuffered() { return false; } /** * Get resource * * @return resource */ public function getResource() { return $this->resource; } /** * Current * * @return mixed */ public function current() { if ($this->currentComplete) { return $this->currentData; } $this->load(); return $this->currentData; } /** * Next * * @return bool */ public function next() { $this->load(); return true; } /** * Load * * @param int $row * @return mixed */ protected function load($row = SQLSRV_SCROLL_NEXT) { $this->currentData = sqlsrv_fetch_array($this->resource, SQLSRV_FETCH_ASSOC, $row); $this->currentComplete = true; $this->position++; return $this->currentData; } /** * Key * * @return mixed */ public function key() { return $this->position; } /** * Rewind * * @return bool */ public function rewind() { $this->position = 0; $this->load(SQLSRV_SCROLL_FIRST); return true; } /** * Valid * * @return bool */ public function valid() { if ($this->currentComplete && $this->currentData) { return true; } return $this->load(); } /** * Count * * @return int */ public function count() { return sqlsrv_num_rows($this->resource); } /** * @return bool|int */ public function getFieldCount() { return sqlsrv_num_fields($this->resource); } /** * Is query result * * @return bool */ public function isQueryResult() { if (is_bool($this->resource)) { return false; } return (sqlsrv_num_fields($this->resource) > 0); } /** * Get affected rows * * @return int */ public function getAffectedRows() { return sqlsrv_rows_affected($this->resource); } /** * @return mixed|null */ public function getGeneratedValue() { return $this->generatedValue; } } |