From 9b6663f87a7e679ffba691cf516191fc840cf978 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 24 Nov 2009 19:20:36 -0800 Subject: Update to Kohana r4684 which is now Kohana 2.4 and has substantial changes. --- system/libraries/Database_Result.php | 170 +++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 system/libraries/Database_Result.php (limited to 'system/libraries/Database_Result.php') diff --git a/system/libraries/Database_Result.php b/system/libraries/Database_Result.php new file mode 100644 index 00000000..cf2056f3 --- /dev/null +++ b/system/libraries/Database_Result.php @@ -0,0 +1,170 @@ +insert_id; + } + + /** + * Return the named column from the current row. + * + * @param string Column name + * @return mixed + */ + public function get($name) + { + // Get the current row + $row = $this->current(); + + if ( ! $this->return_objects) + return $row[$name]; + + return $row->$name; + } + + /** + * Countable: count + */ + public function count() + { + return $this->total_rows; + } + + /** + * ArrayAccess: offsetExists + */ + public function offsetExists($offset) + { + return ($offset >= 0 AND $offset < $this->total_rows); + } + + /** + * ArrayAccess: offsetGet + */ + public function offsetGet($offset) + { + if ( ! $this->seek($offset)) + return NULL; + + return $this->current(); + } + + /** + * ArrayAccess: offsetSet + * + * @throws Kohana_Database_Exception + */ + final public function offsetSet($offset, $value) + { + throw new Kohana_Exception('Database results are read-only'); + } + + /** + * ArrayAccess: offsetUnset + * + * @throws Kohana_Database_Exception + */ + final public function offsetUnset($offset) + { + throw new Kohana_Exception('Database results are read-only'); + } + + /** + * Iterator: key + */ + public function key() + { + return $this->current_row; + } + + /** + * Iterator: next + */ + public function next() + { + ++$this->current_row; + return $this; + } + + /** + * Iterator: prev + */ + public function prev() + { + --$this->current_row; + return $this; + } + + /** + * Iterator: rewind + */ + public function rewind() + { + $this->current_row = 0; + return $this; + } + + /** + * Iterator: valid + */ + public function valid() + { + return $this->offsetExists($this->current_row); + } + +} // End Database_Result \ No newline at end of file -- cgit v1.2.3