An instance of this class is returned by methods of waModel class when SQL SELECT queries are executed.
Methods
-
count
Returns the number of found database records.
-
fetch
Returns the contents of the first found record as a combination of a zero-indexed and associative array.
-
fetchAll
Returns the contents of all found database records as an array of sub-arrays corresponding to individual records.
-
fetchArray
Returns the contents of the first found record as a zero-indexed array.
-
fetchAssoc
Returns the contents of the first found record as an associative array.
-
fetchField
Returns the value of the specified field in the first found record.
-
fetchRow
Alias for method fetchArray.
public function count()
Returns the number of found database records.
Example
$model = new waModel();
$model->query('SELECT * FROM table_name')->count();
public function fetch()
Returns the contents of the first found record as a combination of a zero-indexed and associative array.
Example
$model = new waModel();
$model->query('SELECT * FROM table_name')->fetch();
Result
Array ( 0 => '1' id => '1' 1 => 'John' name => 'John' 2 => '25' age => '25' )
public function fetchAll ($key = null, $normalize = false)
Returns the contents of all found database records as an array of sub-arrays corresponding to individual records. The use of parameters is identical to that described for method getAll of class waModel.
public function fetchArray()
Returns the contents of the first found record as a zero-indexed array.
Example
$model = new waModel();
$model->query('SELECT * FROM table_name')->fetchArray();
Result
Array ( 0 => '1' 1 => 'John' 2 => '25' )
public function fetchAssoc()
Returns the contents of the first found record as an associative array.
$model = new waModel();
$model->query('SELECT * FROM table_name')->fetchAssoc();
Result
Array ( id => '1' name => 'John' age => '25' )
public function fetchField ($field = false, $seek = false)
Returns the value of the specified field in the first found record.
Parameters
-
$field
Optional database field name whose value must be returned. If not specified, the value of the first database field is returned.
-
$seek
Flag requiring to return the value of the next found database record next time this method is called.
Example
$model = new waModel();
$result = $model->query('SELECT * FROM table_name');
$result->fetchField('name', true); //'John'
$result->fetchField('name', true); //'Mary'
$result->fetchField('name', true); //'Bill'
//each call of the method returns the field value of the next found daatbase record if $seek is set to true









