abstract Database_Result
› Kohana_Database_Result
Class Contents
Constants
- None
Properties
- None
Class declared in MODPATH/database/classes/database/result.php on line 3.
Methods
public __construct( )
› Kohana_Database_Result
Source Code
public function __construct($result, $sql, $as_object = FALSE, array $params = NULL)
{
// Store the result locally
$this->_result = $result;
// Store the SQL locally
$this->_query = $sql;
if (is_object($as_object))
{
// Get the object class name
$as_object = get_class($as_object);
}
// Results as objects or associative arrays
$this->_as_object = $as_object;
if ($params)
{
// Object constructor params
$this->_object_params = $params;
}
}
abstract public __destruct( )
› Kohana_Database_Result
Source Code
abstract public function __destruct();
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;
}
abstract public seek( )
› SeekableIterator
public cached( )
› Kohana_Database_Result
Source Code
public function cached()
{
return new Database_Result_Cached($this->as_array(), $this->_query, $this->_as_object);
}
final public offsetUnset( )
› Kohana_Database_Result
Source Code
final public function offsetUnset($offset)
{
throw new Kohana_Exception('Database results are read-only');
}
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 key( )
› Kohana_Database_Result
Source Code
public function key()
{
return $this->_current_row;
}
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 offsetSet( )
› Kohana_Database_Result
Source Code
final public function offsetSet($offset, $value)
{
throw new Kohana_Exception('Database results are read-only');
}
abstract public seek( )
› SeekableIterator
final public offsetUnset( )
› Kohana_Database_Result
Source Code
final public function offsetUnset($offset)
{
throw new Kohana_Exception('Database results are read-only');
}
abstract public current( )
› Iterator
public prev( )
› Kohana_Database_Result
Source Code
public function prev()
{
--$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();
}
public rewind( )
› Kohana_Database_Result
Source Code
public function rewind()
{
$this->_current_row = 0;
return $this;
}
abstract public current( )
› Iterator
public next( )
› Kohana_Database_Result
Source Code
public function next()
{
++$this->_current_row;
return $this;
}
public valid( )
› Kohana_Database_Result
Source Code
public function valid()
{
return $this->offsetExists($this->_current_row);
}
public key( )
› Kohana_Database_Result
Source Code
public function key()
{
return $this->_current_row;
}
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 valid( )
› Kohana_Database_Result
Source Code
public function valid()
{
return $this->offsetExists($this->_current_row);
}