Forum und email

sqlite_fetch_array

SQLiteResult->fetch

SQLiteUnbuffered->fetch

(No version information available, might be only in CVS)

SQLiteUnbuffered->fetch — Fetches the next row from a result set as an array

Popis

array sqlite_fetch_array ( resource $result [, int $result_type [, bool $decode_binary ]] )

Object oriented style (method):

SQLiteResult
array fetch ([ int $result_type [, bool $decode_binary ]] )
SQLiteUnbuffered
array fetch ([ int $result_type [, bool $decode_binary ]] )

Fetches the next row from the given result handle. If there are no more rows, returns FALSE, otherwise returns an associative array representing the row data.

Parametre

result

The SQLite result resource. This parameter is not required when using the object-oriented method.

result_type

Voliteľný result_type parameter akceptuje konštantu a určuje ako sa bude vrátené pole indexovať. Použitie SQLITE_ASSOC vráti iba asociatívne indexy (nazývané polia) zatiaľčo SQLITE_NUM vráti iba číselné indexy (rádové čísla poľa). SQLITE_BOTH vráti obe asociatívne a číselné indexy. SQLITE_BOTH je východzia pre túto funkciu.

decode_binary

Keď sa decode_binary parameter nastaví na TRUE (default), PHP dekóduje kódovanie binárneho súboru, ktorý aplikoval na dáta, ak bol zakódovaný pomocou sqlite_escape_string(). Túto hodnotu by ste mali ponechať vo svojom východzom stave, pokiaľ nespolupracujete s databázami vytvorenými inými sqlite schopnými aplikáciami.

Vrátené hodnoty

Returns an array of the next row from a result set; FALSE if the next position is beyond the final row.

Názvy stĺpcov, ktoré vracajú SQLITE_ASSOC a SQLITE_BOTH budú case-folded (zmenené z malých na veľké al. naopak) podľa nastavenia voľby sqlite.assoc_case.

Príklady

Example#1 Procedural example

<?php
$dbhandle 
sqlite_open('sqlitedb');
$query sqlite_query($dbhandle'SELECT name, email FROM users LIMIT 25');
while (
$entry sqlite_fetch_array($querySQLITE_ASSOC)) {
    echo 
'Name: ' $entry['name'] . '  E-mail: ' $entry['email'];
}
?>

Example#2 Object-oriented example

<?php
$dbhandle 
= new SQLiteDatabase('sqlitedb');

$query $dbhandle->query('SELECT name, email FROM users LIMIT 25'); // buffered result set
$query $dbhandle->unbufferedQuery('SELECT name, email FROM users LIMIT 25'); // unbuffered result set

while ($entry $query->fetch(SQLITE_ASSOC)) {
    echo 
'Name: ' $entry['name'] . '  E-mail: ' $entry['email'];
}
?>