rendered paste bodyclass MysqlResultIterator implements Iterator, Countable {
protected $results;
protected $counter;
protected $counted;
protected $current;
function __construct($results) {
$this->results = $results;
$this->counted = mysql_num_rows($this->results);
$this->counter = 0;
$this->current = null;
$this->rewind();
}
function __destruct() {
mysql_free_result($this->results);
}
function rewind() {
mysql_data_seek($this->results, 0);
$this->current = mysql_fetch_assoc($this->results);
$this->counter = 0;
}
function key() {
return $this->counter;
}
function current() {
return $this->current;
}
function next() {
$this->counter++;
return $this->current = mysql_fetch_assoc($this->results);
}
function valid() {
return $this->counted > $this->counter;
}
function count() {
return $this->counted;
}
}