(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0)
sqlite_array_query -- SQLiteDatabase::arrayQuery — Execute a query against a given database and returns an array
$dbhandle
, string $query
[, int $result_type
= SQLITE_BOTH
[, bool $decode_binary
= TRUE
]] ) : array$query
, resource $dbhandle
[, int $result_type
= SQLITE_BOTH
[, bool $decode_binary
= TRUE
]] ) : array锟斤拷锟斤拷锟斤拷锟斤拷锟� (method):
$query
[, int $result_type
= SQLITE_BOTH
[, bool $decode_binary
= TRUE
]] ) : arraysqlite_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.
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.
query
The query to be executed.
Data inside the query should be properly escaped.
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
锟斤拷选锟斤拷 result_type
锟斤拷锟斤拷锟斤拷锟杰筹拷锟斤拷锟斤拷锟揭撅拷锟斤拷锟斤拷锟截碉拷锟斤拷锟斤拷锟斤拷伪锟斤拷锟斤拷锟斤拷锟绞癸拷锟�
SQLITE_ASSOC
锟斤拷锟斤拷锟斤拷毓锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷侄危锟斤拷锟斤拷锟�
SQLITE_NUM
锟斤拷锟斤拷锟斤拷锟斤拷锟街碉拷锟斤拷锟斤拷锟�SQLITE_BOTH
锟斤拷同时锟斤拷锟截癸拷锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷SQLITE_BOTH
锟角此猴拷锟斤拷锟斤拷默锟斤拷值锟斤拷
decode_binary
锟斤拷
decode_binary
锟斤拷锟斤拷锟斤拷锟斤拷为 TRUE
锟斤拷默锟斤拷值锟斤拷时锟斤拷PHP 锟斤拷锟斤拷锟斤拷锟叫╋拷锟�
sqlite_escape_string()
锟斤拷锟斤拷锟侥讹拷锟斤拷锟斤拷锟斤拷锟捷★拷通锟斤拷应锟斤拷锟斤拷锟斤拷值为锟斤拷默锟斤拷值锟斤拷锟斤拷锟斤拷要锟斤拷锟斤拷锟斤拷使锟斤拷 SQLlite 锟斤拷应锟矫筹拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷斤拷锟斤拷锟斤拷
Note: 为锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷匡拷锟斤拷展(锟斤拷锟斤拷 MySQL)锟斤拷支锟斤拷锟斤拷锟街匡拷锟斤拷锟斤拷锟斤拷锓拷锟斤拷萍锟斤拷锟揭伙拷指锟绞斤拷锟斤拷锟斤拷锟斤拷牡锟揭伙拷锟斤拷锟斤拷锟斤拷锟�
dbhandle
锟斤拷
Returns an array of the entire result set; FALSE
otherwise.
锟斤拷
SQLITE_ASSOC
锟斤拷 SQLITE_BOTH
锟斤拷锟截碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 sqlite.assoc_case
锟斤拷锟斤拷选锟斤拷锟街碉拷锟斤拷锟斤拷锟叫⌒达拷锟�
Example #1 锟斤拷锟教伙拷锟斤拷锟�
<?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'];
}
?>