Рефакторинг

This commit is contained in:
origami11 2017-02-17 15:08:12 +03:00
parent 1b5852cc43
commit 981a1d0f0f
11 changed files with 626 additions and 270 deletions

View file

@ -0,0 +1,46 @@
<?php
class Database_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;
}
}