2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 09:02:41 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.sqlite-query" xmlns="http://docbook.org/ns/docbook">
|
2003-06-20 18:49:38 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>sqlite_query</refname>
|
2005-01-12 08:56:59 +00:00
|
|
|
<refname>SQLiteDatabase->query</refname>
|
|
|
|
<refpurpose>Executes a query against a given database and returns a result handle</refpurpose>
|
2003-06-20 18:49:38 +00:00
|
|
|
</refnamediv>
|
2005-02-21 00:31:07 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2003-06-20 18:49:38 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>resource</type><methodname>sqlite_query</methodname>
|
2003-07-21 16:44:20 +00:00
|
|
|
<methodparam><type>resource</type><parameter>dbhandle</parameter></methodparam>
|
2003-06-20 18:49:38 +00:00
|
|
|
<methodparam><type>string</type><parameter>query</parameter></methodparam>
|
2011-05-17 23:09:17 +00:00
|
|
|
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter><initializer>SQLITE_BOTH</initializer></methodparam>
|
2005-09-09 21:42:13 +00:00
|
|
|
<methodparam choice="opt"><type>string</type><parameter role="reference">error_msg</parameter></methodparam>
|
2003-06-20 18:49:38 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>resource</type><methodname>sqlite_query</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>query</parameter></methodparam>
|
2003-07-21 16:44:20 +00:00
|
|
|
<methodparam><type>resource</type><parameter>dbhandle</parameter></methodparam>
|
2011-05-17 23:09:17 +00:00
|
|
|
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter><initializer>SQLITE_BOTH</initializer></methodparam>
|
2005-09-09 21:42:13 +00:00
|
|
|
<methodparam choice="opt"><type>string</type><parameter role="reference">error_msg</parameter></methodparam>
|
2003-06-20 18:49:38 +00:00
|
|
|
</methodsynopsis>
|
2012-01-11 06:50:17 +00:00
|
|
|
<para>&style.oop; (method):</para>
|
2005-01-12 08:56:59 +00:00
|
|
|
<classsynopsis>
|
|
|
|
<ooclass><classname>SQLiteDatabase</classname></ooclass>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>SQLiteResult</type><methodname>query</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>query</parameter></methodparam>
|
2011-05-17 23:09:17 +00:00
|
|
|
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter><initializer>SQLITE_BOTH</initializer></methodparam>
|
2005-09-09 21:42:13 +00:00
|
|
|
<methodparam choice="opt"><type>string</type><parameter role="reference">error_msg</parameter></methodparam>
|
2005-01-12 08:56:59 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
</classsynopsis>
|
2003-06-20 18:49:38 +00:00
|
|
|
<para>
|
|
|
|
Executes an SQL statement given by the <parameter>query</parameter> against
|
2005-02-21 00:31:07 +00:00
|
|
|
a given database handle.
|
2003-06-20 18:49:38 +00:00
|
|
|
</para>
|
2005-02-21 00:31:07 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2005-09-09 21:42:13 +00:00
|
|
|
<term><parameter>dbhandle</parameter></term>
|
2005-02-21 00:31:07 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-09-09 21:42:13 +00:00
|
|
|
The SQLite Database resource; returned from
|
|
|
|
<function>sqlite_open</function> when used procedurally. This parameter
|
|
|
|
is not required when using the object-oriented method.
|
2005-02-21 00:31:07 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2005-09-09 21:42:13 +00:00
|
|
|
<term><parameter>query</parameter></term>
|
2005-02-21 00:31:07 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-09-09 21:42:13 +00:00
|
|
|
The query to be executed.
|
2005-02-21 00:31:07 +00:00
|
|
|
</para>
|
2009-07-30 12:22:29 +00:00
|
|
|
<para>
|
|
|
|
Data inside the query should be <link
|
|
|
|
linkend="function.sqlite-escape-string">properly escaped</link>.
|
|
|
|
</para>
|
2005-02-21 00:31:07 +00:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2005-06-16 15:16:21 +00:00
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>result_type</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
&sqlite.result-type;
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2005-09-09 21:42:13 +00:00
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>error_msg</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The specified variable will be filled if an error occurs. This is
|
|
|
|
specially important because SQL syntax errors can't be fetched using
|
|
|
|
the <function>sqlite_last_error</function> function.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2005-02-21 00:31:07 +00:00
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
&sqlite.param-compat;
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
2003-06-20 18:49:38 +00:00
|
|
|
<para>
|
2009-11-09 10:26:08 +00:00
|
|
|
This function will return a result handle&return.falseforfailure;.
|
2004-08-16 09:29:35 +00:00
|
|
|
For queries that return rows, the result handle can then be used with
|
|
|
|
functions such as <function>sqlite_fetch_array</function> and
|
2003-06-20 18:49:38 +00:00
|
|
|
<function>sqlite_seek</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Regardless of the query type, this function will return &false; if the
|
|
|
|
query failed.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<function>sqlite_query</function> returns a buffered, seekable result
|
|
|
|
handle. This is useful for reasonably small queries where you need to
|
|
|
|
be able to randomly access the rows. Buffered result handles will
|
|
|
|
allocate memory to hold the entire result and will not return until it
|
|
|
|
has been fetched. If you only need sequential access to the data, it is
|
|
|
|
recommended that you use the much higher performance
|
|
|
|
<function>sqlite_unbuffered_query</function> instead.
|
|
|
|
</para>
|
2005-02-21 00:31:07 +00:00
|
|
|
</refsect1>
|
|
|
|
|
2005-09-09 21:42:13 +00:00
|
|
|
<refsect1 role="changelog">
|
|
|
|
&reftitle.changelog;
|
|
|
|
<para>
|
|
|
|
<informaltable>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>&Version;</entry>
|
|
|
|
<entry>&Description;</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry>5.1.0</entry>
|
|
|
|
<entry>
|
|
|
|
Added the <parameter>error_msg</parameter> parameter
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</informaltable>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2005-02-21 00:31:07 +00:00
|
|
|
<refsect1 role="notes">
|
|
|
|
&reftitle.notes;
|
2003-06-20 18:49:38 +00:00
|
|
|
<warning>
|
|
|
|
<simpara>
|
|
|
|
SQLite <emphasis>will</emphasis> execute multiple queries separated by
|
|
|
|
semicolons, so you can use it to execute a batch of SQL that you have
|
2004-05-13 14:32:21 +00:00
|
|
|
loaded from a file or have embedded in a script. However, this works only
|
|
|
|
when the result of the function is not used - if it is used,
|
|
|
|
only the first SQL statement would be executed. Function
|
|
|
|
<function>sqlite_exec</function> will always execute multiple SQL
|
|
|
|
statements.
|
2003-06-20 18:49:38 +00:00
|
|
|
</simpara>
|
|
|
|
<simpara>
|
|
|
|
When executing multiple queries, the return value of this function
|
2004-09-17 10:26:59 +00:00
|
|
|
will be &false; if there was an error, but undefined otherwise (it might
|
2003-06-20 18:49:38 +00:00
|
|
|
be &true; for success or it might return a result handle).
|
|
|
|
</simpara>
|
|
|
|
</warning>
|
2005-02-21 00:31:07 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2003-06-20 18:49:38 +00:00
|
|
|
<para>
|
2005-02-21 00:31:07 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>sqlite_unbuffered_query</function></member>
|
|
|
|
<member><function>sqlite_array_query</function></member>
|
|
|
|
</simplelist>
|
2003-06-20 18:49:38 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2005-02-21 00:31:07 +00:00
|
|
|
|
2003-06-20 17:31:55 +00:00
|
|
|
<!-- 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
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2003-06-20 17:31:55 +00:00
|
|
|
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
|
|
|
|
-->
|