Its prototype follows:
array sqlite_array_query(resource dbh, string query [, int res_type
[, bool decode_binary]])
The input parameters work exactly like those introduced in the component functions
sqlite_query() and sqlite_fetch_array(). According to the PHP manual, this
function should only be used for retrieving result sets of fewer than 45 rows. However, in
instances where 45 or fewer rows are involved, this function provides both a considerable
improvement in performance and, in certain cases, a slight reduction in total lines
of code. Consider an example:
$sqldb = sqlite_open("corporate.db");
$rows = sqlite_array_query($sqldb, "SELECT empid, name FROM employees");
foreach ($rows AS $row) {
echo $row["name"]." (Employee ID: ".$row["empid"].")
";
}
sqlite_close($sqldb);
?>
This returns the following:
Jason Gilmore (Employee ID: 1)
Sam Spade (Employee ID: 2)
Ray Fox (Employee ID: 3)
Retrieving Select Result Set Columns
The sqlite_column() function is useful if you??™re interested in just a single column
from a given result row or set. Its prototype follows:
mixed sqlite_column(resource result, mixed index_or_name [, bool decode_binary])
You can retrieve the column either by name or by index offset. Finally, the optional
decode_binary parameter determines whether PHP will decode the binary-encoded
CHAPTER 22 ?– SQLITE 579
target data that had been previously encoded using the function sqlite_escape_
string().
Pages:
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664