Retrieving the Number of Columns in the Result Set
The sqlite_num_fields() function returns the number of columns located in the
result set. Its prototype follows:
int sqlite_num_fields(resource result_set)
An example follows:
$sqldb = sqlite_open("corporate.db");
$results = sqlite_query($sqldb, "SELECT * FROM employees");
echo "Total fields returned: ".sqlite_num_fields($results)."
";
sqlite_close($sqldb);
?>
This returns the following:
Total fields returned: 3
Retrieving the Number of Rows in the Result Set
The sqlite_num_rows() function returns the number of rows located in the result set.
Its prototype follows:
int sqlite_num_rows(resource result_set)
An example follows:
582 CHAPTER 22 ?– SQLITE
$sqldb = sqlite_open("corporate.db");
$results = sqlite_query($sqldb, "SELECT * FROM employees");
echo "Total rows returned: ".sqlite_num_rows($results)."
";
sqlite_close($sqldb);
?>
This returns the following:
Total rows returned: 3
Retrieving the Number of Affected Rows
The sqlite_changes() function returns the total number of rows affected by the most
recent modification query. Its prototype follows:
int sqlite_changes(resource dbh)
For instance, if an UPDATE query modifies a field located in 12 rows, executing this
function following that query would return 12.
Manipulating the Result Set Pointer
Although SQLite is indeed a database server, in many ways it behaves much like what you
experience when working with file I/O.
Pages:
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667