php-doc-en/reference/sqlite/functions/sqlite-array-query.xml
Kenneth Schwartz ecb62a3422 add/update examples
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@177651 c90b9560-bf6c-de11-be94-00142212c4b1
2005-01-19 13:55:43 +00:00

120 lines
4.1 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<refentry id="function.sqlite-array-query">
<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>
<title>Description</title>
<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></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter></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></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter></methodparam>
</methodsynopsis>
<para>Object oriented style (method):</para>
<classsynopsis>
<ooclass><classname>SQLiteDatabase</classname></ooclass>
<methodsynopsis>
<type>array</type><methodname>arrayQuery</methodname>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<para>
<function>sqlite_array_query</function> is similar to calling
<function>sqlite_query</function> and then
<function>sqlite_fetch_array</function> for each row of the result set
and storing it into an array, as shown in the example below. Calling
<function>sqlite_array_query</function> is significantly faster than
using such a script.
</para>
&sqlite.result-type;
&sqlite.case-fold;
&sqlite.decode-bin;
<para>
<example>
<title><function>sqlite_array_query</function> implemented yourself</title>
<programlisting role="php">
<![CDATA[
<?php
$q = sqlite_query($dbhandle, "SELECT name, email FROM users LIMIT 25");
$rows = array();
while ($r = sqlite_fetch_array($q)) {
$rows[] = $r;
}
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title><function>sqlite_array_query</function> example</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]";
}
/* OO Example */
$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>
<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>
&sqlite.param-compat;
<para>
See also <function>sqlite_query</function>,
<function>sqlite_fetch_array</function>, and
<function>sqlite_fetch_string</function>.
</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:"../../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
-->