Iterator = new \Phacil\Framework\Databases\Object\Result($results); elseif($results instanceof \Phacil\Framework\Databases\Object\ResultInterface) $this->Iterator = $results; parent::__construct($this->Iterator, $flags); //$this->num_rows = $this->count(); return $this; } /** * * @param string $name * @return \Phacil\Framework\Databases\Object\ItemInterface[]|\Phacil\Framework\Databases\Object\ItemInterface|null * @throws \Phacil\Framework\Exception\RuntimeException */ public function __get($name) { switch ($name) { case 'rows': return $this->__toArray(); break; case 'row': return $this->offsetGet(0); break; default: throw new \Phacil\Framework\Exception\RuntimeException("Undefined property: $name"); break; } } /** * * {@inheritdoc} */ public function getData($numRow = false) { return $numRow ? $this->getRow($numRow) : $this->getRows(); } /** * {@inheritdoc} */ public function getItems() { return $this->__toObject(); } /** * {@inheritdoc} */ public function setRows($rows) { $this->rows = $rows; $this->row = isset($rows[0]) ? $this->rows[0] : null; return $this; } /** * {@inheritdoc} */ public function getRows() { return $this->rows; } /** * {@inheritdoc} */ public function setRow($row) { $this->row = $row; return $this; } /** * {@inheritdoc} */ public function getRow($numRow = false) { return ($numRow ? ($this->offsetGet($numRow - 1) ?: null) : $this->row); } /** * * {@inheritdoc} */ public function setNumRows($num) { $this->num_rows = $num; return $this; } /** * {@inheritdoc} */ public function getNumRows() { return $this->num_rows; } /** * {@inheritdoc} */ public function __toObject() { return $this; } /** * {@inheritdoc} */ public function __toArray() { //return iterator_to_array($this); foreach ($this as $val) { # nothing } return $this->getCache(); } /** * {@inheritdoc} */ public function offsetGet($index) { $data = null; if ($this->offsetExists($index)) { $data = parent::offsetGet($index); } elseif ($this->Iterator->offsetExists($index)){ $data = $this->Iterator->offsetGet($index); } if(!$data) return null; $item = new \Phacil\Framework\Databases\Object\Item($data); return $item; } }