Retrieves data from the database.
Syntax
DB::Select($table, $values)
// or
DB::Select($table, $where)
Arguments
$table
the table from which the data is selected.
$values
an array with values that define the condition of the Select query.
$where
the condition for the Select query.
Return value
An array with the result of the Select query.
Example 1
Retrieve all data from the Cars table where the make is Toyota and the model is RAV4.
$data = array();
$data["make"] = "Toyota";
$data["model"] = "RAV4";
$rs = DB::Select("Cars", $data );
while( $record = $rs->fetchAssoc() )
{
echo $record["id"];
echo $record["make"];
}
Example 2
Retrieve all data from the Cars table where the price is less than 20,000.
$rs = DB::Select("Cars", "Price<20000" );
while( $record = $rs->fetchAssoc() )
{
echo $record["id"];
echo $record["make"];
}
See also:
•QueryResult object: fetchAssoc()
•QueryResult object: fetchNumeric()