Рефакторинг
This commit is contained in:
parent
1b5852cc43
commit
981a1d0f0f
11 changed files with 626 additions and 270 deletions
46
src/Database/StatementIterator.php
Normal file
46
src/Database/StatementIterator.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue