The offset always begins with 0, not 1, which is why you
CHAPTER 22 ?– SQLITE 585
need to subtract 1 from the total rows returned in this example. As a result, the randomly
generated row offset integer must fall within a range of 0 and one less than the total
number of returned rows.
Retrieving a Table??™s Column Types
The function sqlite_fetch_column_types() returns an array consisting of the column
types located in a table. Its prototype follows:
array sqlite_fetch_column_types(string table, resource dbh)
The returned array includes both the associative and numerical hash indices. The
following example outputs an array of column types located in the employees table
used earlier in this chapter:
$sqldb = sqlite_open("corporate.db");
$columnTypes = sqlite_fetch_column_types("employees", $sqldb);
print_r($columnTypes);
sqlite_close($sqldb);
?>
This example returns the following (formatted for readability):
Array (
[empid] => integer
[name] => varchar(25)
[title] => varchar(25)
)
Working with Binary Data
SQLite is capable of storing binary information in a table, such as a GIF or a JPEG
image, a PDF document, or a Microsoft Word document. However, unless you treat
this data carefully, errors in both storage and communication could arise. Several
functions are available for carrying out the tasks necessary for managing this data,
one of which is introduced in this section.
Pages:
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670