49 lines
941 B
PHP
49 lines
941 B
PHP
<?php
|
|
|
|
namespace ctiso\Database;
|
|
use PDO;
|
|
|
|
class StatementIterator implements Iterator
|
|
{
|
|
|
|
private $result;
|
|
private $pos = 0;
|
|
private $fetchmode;
|
|
private $row_count;
|
|
|
|
public function __construct(/*.Database_PDOStatement.*/ $rs) {
|
|
$this->result = $rs;
|
|
$this->row_count = $rs->getRecordCount();
|
|
}
|
|
|
|
function rewind() {
|
|
$this->pos = 0;
|
|
}
|
|
|
|
function valid() {
|
|
return ($this->pos < $this->row_count);
|
|
}
|
|
|
|
function key() {
|
|
return $this->pos;
|
|
}
|
|
|
|
function current() {
|
|
if (!isset($this->result->cache[$this->pos])) {
|
|
$this->result->cache[$this->pos] = $this->result->fetch(PDO::FETCH_ASSOC);
|
|
}
|
|
return $this->result->cache[$this->pos];
|
|
}
|
|
|
|
function next() {
|
|
$this->pos++;
|
|
}
|
|
|
|
function seek($index) {
|
|
$this->pos = $index;
|
|
}
|
|
|
|
function count() {
|
|
return $this->row_count;
|
|
}
|
|
}
|