sqlite_array_query

SQLiteDatabase::arrayQuery

(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0)

sqlite_array_query -- SQLiteDatabase::arrayQueryExecute a query against a given database and returns an array

설명

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

객체 기반 형식 (method):

public array SQLiteDatabase::arrayQuery ( string $query [, int $result_type = SQLITE_BOTH [, bool $decode_binary = true ]] )

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.

인수

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()를 사용하여 인코드한 데이터로 취급하여 이진 인코딩을 해제합니다. 다른 sqlite 적용 프로그램에서 생성한 데이터베이스를 사용하지 않는 한, 기본값으로 사용하면 됩니다.

Note: (MySQL 같은) 다른 데이터베이스 확장과 호환성을 유지하기 위하여 두가지 다른 형식의 문법을 지원합니다. 권장하는 방식은 dbhandle 인수를 함수의 첫번째 인수로 사용하는 것입니다.

반환값

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

SQLITE_ASSOCSQLITE_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'];
}
?>

참고

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top