class BufferedResult { private $buffer; public function __construct($result) { while ($row = $result->fetchRow()) { $this->buffer[] = $row; }} public function fetchRow($mode) { return array_shift($this->buffer); } public function fetchAll() { return array_splice($this->buffer, 0); } }