sqlite_fetch_row
Fetches the current row from a result and then advances to the next row.
Syntax
$sqlite_fetch_row ( result, hash_table [, result_type ] )
|
Parameters
result
The result identifier.
hash_table
The name of the hash table to where to store the row data.
result_type
The type of the result. Optional, see remarks for more info.
Return Value
1 on success; Otherwise 0 if there are no more rows available, or $null if there was an error.
Remarks
$sqlite_fetch_row fetches the next row from the result and stores the data in hash_table.If the hash table doesn't exist, it will be created; Otherwise it will be cleared before new data is stored.
result_type specifies how the hash table is created, it can be one of the following: $SQLITE_NUM, $SQLITE_ASSOC or $SQLITE_BOTH. $SQLITE_BOTH is default.
If $SQLITE_NUM is used, the hash table items will be field indexes, starting from index 1. If $SQLITE_ASSOC is used, the items will be field names. If $SQLITE_BOTH is used, both column indexes and names are used.
In case of $SQLITE_BOTH, if some of the column names are identical to another columns' index, the index has priority and will be used as an item.
Example
; This code assumes a connection is already established and stored in %db
var %sql = SELECT first_name, last_name FROM contacts var %res = $sqlite_query(%db, %sql) if (%res) { echo -a Fetching results... echo -a - while ($sqlite_fetch_row(%res, row, $SQLITE_ASSOC)) { ; If you used $SQLITE_FETCH_NUM or $SQLITE_FETCH_BOTH you could use 1 instead of first_name and 2 instead of last_name echo -a First name: $hget(row, first_name) echo -a Last name: $hget(row, last_name) echo -a - } sqlite_free %res } else { echo -a Error executing query: %sqlite_errstr } |