php-doc-en/reference/sqlite/functions/sqlite-array-query.xml
2013-06-18 05:36:30 +00:00

168 lines
5.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.sqlite-array-query" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>sqlite_array_query</refname>
<refname>SQLiteDatabase::arrayQuery</refname>
<refpurpose>Execute a query against a given database and returns an array</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>sqlite_array_query</methodname>
<methodparam><type>resource</type><parameter>dbhandle</parameter></methodparam>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter><initializer>SQLITE_BOTH</initializer></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter><initializer>true</initializer></methodparam>
</methodsynopsis>
<methodsynopsis>
<type>array</type><methodname>sqlite_array_query</methodname>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam><type>resource</type><parameter>dbhandle</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter><initializer>SQLITE_BOTH</initializer></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter><initializer>true</initializer></methodparam>
</methodsynopsis>
<para>&style.oop; (method):</para>
<methodsynopsis>
<modifier>public</modifier> <type>array</type><methodname>SQLiteDatabase::arrayQuery</methodname>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter><initializer>SQLITE_BOTH</initializer></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter><initializer>true</initializer></methodparam>
</methodsynopsis>
<para>
<function>sqlite_array_query</function> executes the given query and returns
an array of the entire result set. It is similar to calling
<function>sqlite_query</function> and then <function>sqlite_fetch_array</function>
for each row in the result set. <function>sqlite_array_query</function> is
significantly faster than the aforementioned.
</para>
<tip>
<para>
<function>sqlite_array_query</function> 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
<function>sqlite_unbuffered_query</function> instead for more optimal
performance.
</para>
</tip>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>query</parameter></term>
<listitem>
<para>
The query to be executed.
</para>
<para>
Data inside the query should be <link
linkend="function.sqlite-escape-string">properly escaped</link>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>dbhandle</parameter></term>
<listitem>
<para>
The SQLite Database resource; returned from <function>sqlite_open</function>
when used procedurally. This parameter is not required
when using the object-oriented method.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>result_type</parameter></term>
<listitem>
&sqlite.result-type;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>decode_binary</parameter></term>
<listitem>
&sqlite.decode-bin;
</listitem>
</varlistentry>
</variablelist>
</para>
&sqlite.param-compat;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an array of the entire result set; &false; otherwise.
</para>
&sqlite.case-fold;
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>&style.procedural;</title>
<programlisting role="php">
<![CDATA[
<?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'];
}
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Object-oriented style</title>
<programlisting role="php">
<![CDATA[
<?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'];
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>sqlite_query</function></member>
<member><function>sqlite_fetch_array</function></member>
<member><function>sqlite_fetch_string</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->