Forum und email

sqlite_array_query

SQLiteDatabase->arrayQuery

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

SQLiteDatabase->arrayQuery — Execute a query against a given database and returns an array

Popis

array sqlite_array_query ( resource $dbhandle , string $query [, int $result_type [, bool $decode_binary ]] )
array sqlite_array_query ( string $query , resource $dbhandle [, int $result_type [, bool $decode_binary ]] )

Object oriented style (method):

SQLiteDatabase
array arrayQuery ( string $query [, int $result_type [, bool $decode_binary ]] )

sqlite_array_query() executes the given query and returns an array of the entire result set. It is similar to calling sqlite_query() and then sqlite_fetch_array() for each row in the result set. sqlite_array_query() is significantly faster than the aforementioned.

Tip

sqlite_array_query() is best suited to queries returning 45 rows or less. If you have more data than that, it is recommended that you write your scripts to use sqlite_unbuffered_query() instead for more optimal performance.

Parametre

query

The query to be executed.

dbhandle

The SQLite Database resource; returned from sqlite_open() when used procedurally. 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.

Note: Sú podporované dva alternatívne syntaxe kvôli kompatibilite s inými databázovými rozšíreniami (ako MySQL). Preferovaná forma je prvá, kde parameter dbhandle je prvým parametrom funkcie.

Vrátené hodnoty

Returns an array of the entire result set; FALSE otherwise.

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 style

<?php
$dbhandle 
sqlite_open('sqlitedb');
$result sqlite_array_query($dbhandle'SELECT name, email FROM users LIMIT 25'SQLITE_ASSOC);
foreach (
$result as $entry) {
    echo 
'Name: ' $entry['name'] . '  E-mail: ' $entry['email'];
}
?>

Example#2 Object-oriented style

<?php
$dbhandle 
= new SQLiteDatabase('sqlitedb');
$result $dbhandle->arrayQuery('SELECT name, email FROM users LIMIT 25'SQLITE_ASSOC);
foreach (
$result as $entry) {
    echo 
'Name: ' $entry['name'] . '  E-mail: ' $entry['email'];
}
?>