Methods

Sets the total number of rows and stores the result locally.

__construct(mixed $result, string $sql, mixed $as_object) 

Parameters

$result

mixed

query result

$sql

string

SQL query

$as_object

mixed

object

Result destruction cleans up all open result sets.

__destruct() : void

Return all of the rows in the result as an array.

as_array(string $key, string $value) : array

// Indexed array of all rows $rows = $result->as_array();

// Associative array of rows by "id"
$rows = $result->as_array('id');

// Associative array of rows, "id" => "name"
$rows = $result->as_array('id', 'name');

Parameters

$key

string

column for associative keys

$value

string

column for values

Returns

array

Get a cached database result from the current result iterator.

cached() : \Fuel\Core\Database_Result

$cachable = serialize($result->cached());

since 3.0.5

Returns

Implements [Countable::count], returns the total number of rows.

count() : integer

echo count($result);

Returns

integer

Implements [Iterator::current], returns the current row.

current() : mixed

Returns

mixed

Return the named column from the current row.

get(string $name, mixed $default) : mixed

// Get the "id" value $id = $result->get('id');

Parameters

$name

string

column to get

$default

mixed

default value if the column does not exist

Returns

mixed

Implements [Iterator::key], returns the current row number.

key() : integer

Returns

integer

Implements [Iterator::rewind], sets the current row to -1.

rewind() 

Enable sanitization mode in the object

sanitize() : \Fuel\Core\Database_Result

fluent This method is part of a fluent interface and will return the same instance

Returns

Returns the current sanitization state of the object

sanitized() : bool

Returns

bool

Disable sanitization mode in the object

unsanitize() : \Fuel\Core\Database_Result

fluent This method is part of a fluent interface and will return the same instance

Returns

Implements [Iterator::valid], checks if the current row exists.

valid() : boolean

Returns

boolean

 Properties

 

<p>return rows as an object or associative array</p>

$_as_object : bool

 

<p>current row number</p>

$_current_row : int

 

<p>Executed SQL for this result</p>

$_query : string

 

<p>raw result resource</p>

$_result : resource

 

<p>cached result data</p>

$_results : array

 

<p>current row</p>

$_row : mixed

 

<p>If this is a records data will be sanitized on get</p>

$_sanitization_enabled : bool

 

<p>total number of rows</p>

$_total_rows : int