Database_Result_Cached
› Kohana_Database_Result_Cached
› Database_Result
› Kohana_Database_Result
Class Contents
Constants
- None
Properties
- None
Class declared in MODPATH/database/classes/database/result/cached.php on line 3.
Methods
public __construct( )
› Kohana_Database_Result_Cached
Source Code
public function __construct(array $result, $sql, $as_object = NULL)
{
parent::__construct($result, $sql, $as_object);
// Find the number of rows in the result
$this->_total_rows = count($result);
}
public __destruct( )
› Kohana_Database_Result_Cached
Source Code
public function __destruct()
{
// Cached results do not use resources
}
public cached( )
› Kohana_Database_Result_Cached
Source Code
public function cached()
{
return $this;
}
public current( )
› Kohana_Database_Result_Cached
Source Code
public function current()
{
// Return an array of the row
return $this->valid() ? $this->_result[$this->_current_row] : FALSE;
}
public seek( )
› Kohana_Database_Result_Cached
Source Code
public function seek($offset)
{
if ($this->offsetExists($offset))
{
$this->_current_row = $offset;
return TRUE;
}
else
{
return FALSE;
}
}
public current( )
› Kohana_Database_Result_Cached
Source Code
public function current()
{
// Return an array of the row
return $this->valid() ? $this->_result[$this->_current_row] : FALSE;
}
public key( )
› Kohana_Database_Result
Source Code
public function key()
{
return $this->_current_row;
}
public seek( )
› Kohana_Database_Result_Cached
Source Code
public function seek($offset)
{
if ($this->offsetExists($offset))
{
$this->_current_row = $offset;
return TRUE;
}
else
{
return FALSE;
}
}
public next( )
› Kohana_Database_Result
Source Code
public function next()
{
++$this->_current_row;
return $this;
}
public key( )
› Kohana_Database_Result
Source Code
public function key()
{
return $this->_current_row;
}
public offsetExists( )
› Kohana_Database_Result
Source Code
public function offsetExists($offset)
{
return ($offset >= 0 AND $offset < $this->_total_rows);
}
public as_array( )
› Kohana_Database_Result
Source Code
public function as_array($key = NULL, $value = NULL)
{
$results = array();
if ($key === NULL AND $value === NULL)
{
// Indexed rows
foreach ($this as $row)
{
$results[] = $row;
}
}
elseif ($key === NULL)
{
// Indexed columns
if ($this->_as_object)
{
foreach ($this as $row)
{
$results[] = $row->$value;
}
}
else
{
foreach ($this as $row)
{
$results[] = $row[$value];
}
}
}
elseif ($value === NULL)
{
// Associative rows
if ($this->_as_object)
{
foreach ($this as $row)
{
$results[$row->$key] = $row;
}
}
else
{
foreach ($this as $row)
{
$results[$row[$key]] = $row;
}
}
}
else
{
// Associative columns
if ($this->_as_object)
{
foreach ($this as $row)
{
$results[$row->$key] = $row->$value;
}
}
else
{
foreach ($this as $row)
{
$results[$row[$key]] = $row[$value];
}
}
}
$this->rewind();
return $results;
}
public count( )
› Kohana_Database_Result
Source Code
public function count()
{
return $this->_total_rows;
}
public get( )
› Kohana_Database_Result
Source Code
public function get($name, $default = NULL)
{
$row = $this->current();
if ($this->_as_object)
{
if (isset($row->$name))
return $row->$name;
}
else
{
if (isset($row[$name]))
return $row[$name];
}
return $default;
}
public valid( )
› Kohana_Database_Result
Source Code
public function valid()
{
return $this->offsetExists($this->_current_row);
}
public offsetGet( )
› Kohana_Database_Result
Source Code
public function offsetGet($offset)
{
if ( ! $this->seek($offset))
return NULL;
return $this->current();
}
final public offsetSet( )
› Kohana_Database_Result
Source Code
final public function offsetSet($offset, $value)
{
throw new Kohana_Exception('Database results are read-only');
}
final public offsetUnset( )
› Kohana_Database_Result
Source Code
final public function offsetUnset($offset)
{
throw new Kohana_Exception('Database results are read-only');
}
public next( )
› Kohana_Database_Result
Source Code
public function next()
{
++$this->_current_row;
return $this;
}
public offsetExists( )
› Kohana_Database_Result
Source Code
public function offsetExists($offset)
{
return ($offset >= 0 AND $offset < $this->_total_rows);
}
public offsetGet( )
› Kohana_Database_Result
Source Code
public function offsetGet($offset)
{
if ( ! $this->seek($offset))
return NULL;
return $this->current();
}
final public offsetSet( )
› Kohana_Database_Result
Source Code
final public function offsetSet($offset, $value)
{
throw new Kohana_Exception('Database results are read-only');
}
final public offsetUnset( )
› Kohana_Database_Result
Source Code
final public function offsetUnset($offset)
{
throw new Kohana_Exception('Database results are read-only');
}
public prev( )
› Kohana_Database_Result
Source Code
public function prev()
{
--$this->_current_row;
return $this;
}
public count( )
› Kohana_Database_Result
Source Code
public function count()
{
return $this->_total_rows;
}
public rewind( )
› Kohana_Database_Result
Source Code
public function rewind()
{
$this->_current_row = 0;
return $this;
}
public rewind( )
› Kohana_Database_Result
Source Code
public function rewind()
{
$this->_current_row = 0;
return $this;
}
public valid( )
› Kohana_Database_Result
Source Code
public function valid()
{
return $this->offsetExists($this->_current_row);
}