wez Fri Jun 20 13:31:55 2003 EDT Added files: /phpdoc/en/reference/sqlite .cvsignore constants.xml ini.xml reference.xml /phpdoc/en/reference/sqlite/functions sqlite-array-query.xml sqlite-busy-timeout.xml sqlite-changes.xml sqlite-close.xml sqlite-column.xml sqlite-create-function.xml sqlite-current.xml sqlite-error-string.xml sqlite-escape-string.xml sqlite-fetch-array.xml sqlite-fetch-string.xml sqlite-field-name.xml sqlite-has-more.xml sqlite-last-error.xml sqlite-last-insert-rowid.xml sqlite-libencoding.xml sqlite-libversion.xml sqlite-next.xml sqlite-num-fields.xml sqlite-num-rows.xml sqlite-open.xml sqlite-popen.xml sqlite-query.xml sqlite-register-aggregate.xml sqlite-rewind.xml sqlite-seek.xml sqlite-unbuffered-query.xml Log: First run at documentation for the SQLite extension. Many thanks to Johann :)
Index: phpdoc/en/reference/sqlite/.cvsignore +++ phpdoc/en/reference/sqlite/.cvsignore functions.xml
Index: phpdoc/en/reference/sqlite/constants.xml +++ phpdoc/en/reference/sqlite/constants.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <sect2 id="pecl.sqlite.constants"> <title>Predefined constants</title> <para> The functions <function>sqlite_fetch_array</function> and <function>sqlite_current</function> use a constant for the different types of result arrays. The following constants are defined: <table> <title>SQLite fetch constants</title> <tgroup cols="2"> <thead> <row> <entry>constant</entry> <entry>meaning</entry> </row> </thead> <tbody> <row> <entry>SQLITE_ASSOC</entry> <entry> Columns are returned into the array having the fieldname as the array index. </entry> </row> <row> <entry>SQLITE_BOTH</entry> <entry> Columns are returned into the array having both a numerical index and the fieldname as the array index. </entry> </row> <row> <entry>SQLITE_NUM</entry> <entry> Columns are returned into the array having a numerical index to the fields. This index starts with 0, the first field in the result. </entry> </row> </tbody> </tgroup> </table> </para> </sect2> <!-- 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 indent-tabs-mode:nil 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 --> Index: phpdoc/en/reference/sqlite/ini.xml +++ phpdoc/en/reference/sqlite/ini.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <sect2 id="sqlite.configuration"> &reftitle.runtime; &extension.runtime; <para> <table> <title>SQLite Configuration Options</title> <tgroup cols="3"> <thead> <row> <entry>Name</entry> <entry>Default</entry> <entry>Changeable</entry> </row> </thead> <tbody> <row> <entry>sqlite.assoc_case</entry> <entry>0</entry> <entry>PHP_INI_SYSTEM</entry> </row> </tbody> </tgroup> </table> For further details and definition of the PHP_INI_* constants see <function>ini_set</function>. </para> <para> Here is a short explanation of the configuration directives. <variablelist> <varlistentry id="ini.sqlite.assoc-case"> <term> <parameter>sqlite.assoc_case</parameter> <type>int</type> </term> <listitem> <para> Whether to use mixed case (<literal>0</literal>), upper case (<literal>1</literal>) or lower case (<literal>2</literal>) hash indexes. </para> <para> This option is primarily useful when you need compatibility with other database systems, where the names of the columns are always returned as uppercase or lowercase, regardless of the case of the actual field names in the database schema. </para> <para> The SQLite library returns the column names in their natural case (that matches the case you used in your schema). When <parameter>sqlite.assoc_case</parameter> is set to <literal>0</literal> the natural case will be preserved. When it is set to <literal>1</literal> or <literal>2</literal>, PHP will apply case folding on the hash keys to upper- or lower-case the keys, respectively. </para> <para> Use of this option incurrs a slight performance penalty, but is MUCH faster than performing the case folding yourself using PHP script. </para> </listitem> </varlistentry> </variablelist> </para> </sect2> <!-- 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 indent-tabs-mode:nil 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 --> Index: phpdoc/en/reference/sqlite/reference.xml +++ phpdoc/en/reference/sqlite/reference.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <reference id="ref.sqlite"> <title>SQLite</title> <titleabbrev>SQLite</titleabbrev> <partintro> &warn.experimental; <sect1 id="sqlite.partintro"> &reftitle.intro; <sect2 id="sqlite.intro"> <title>About SQLite</title> <para> This is an extension for the SQLite Embeddable SQL Database Engine. SQLite is a C library that implements an embeddable SQL database engine. Programs that link with the SQLite library can have SQL database access without running a separate RDBMS process. </para> <para> SQLite is not a client library used to connect to a big database server. SQLite is the server. The SQLite library reads and writes directly to and from the database files on disk. </para> <note> <para> For further information see the SQLite Website (<ulink url="http://www.sqlite.org">http://www.sqlite.org</ulink>). </para> </note> </sect2> <sect2 id="sqlite.install"> <title>Installation</title> <para> Read the INSTALL file, which comes with the package. Or just use the PEAR installer with "pear install sqlite". SQLite itself is already included, You do not need to install any additional software. </para> <para> You can download the Windows version of the extension from <ulink url="http://snaps.php.net/win32/PECL_STABLE/php_sqlite.dll" >http://snaps.php.net/win32/PECL_STABLE/php_sqlite.dll</ulink> </para> </sect2> <sect2 id="sqlite.contact"> <title>Contact Information</title> <para> Any questions about the extension should be asked on one of the <ulink url="&url.php.support;">PHP Mailing lists</ulink>. </para> </sect2> <sect2 id="sqlite.requirements"> &reftitle.required; <para> In order to have these functions available, you must compile PHP with SQLite support, or load the SQLite extension dynamically from your php.ini. </para> </sect2> <sect2 id="sqlite.resources"> &reftitle.resources; <para> There are two resources used in the SQLite Interface. The first one is the database connection, the second one the result set. </para> </sect2> &reference.sqlite.constants; &reference.sqlite.ini; </sect1> </partintro> &reference.sqlite.functions; </reference> <!-- 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 indent-tabs-mode:nil 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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-array-query.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-array-query.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-array-query"> <refnamediv> <refname>sqlite_array_query</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>db</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> <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> <example> <title><function>sqlite_array_query</function> implemented yourself</title> <programlisting role="php"><![CDATA[<?php $q = sqlite_query($database, "SELECT * from foo LIMIT 100"); $rows = array(); while ($r = sqlite_fetch_array($q)) { $rows[] = $r; } ?>]]> </programlisting> </example> <note> <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> </note> </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-busy-timeout.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-busy-timeout.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-busy-timeout"> <refnamediv><refname>sqlite_busy_timeout</refname> <refpurpose>Set busy timeout duration, or disable busy handlers</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>void</type><function>sqlite_busy_timeout</function> <methodparam><type>resource</type><parameter>database</parameter></methodparam> <methodparam><type>int</type><parameter>milliseconds</parameter></methodparam> </methodsynopsis> <para> Set the maximum time that sqlite will wait for a <parameter>database</parameter> to become ready for use to <parameter>milliseconds</parameter>. If <parameter>milliseconds</parameter> is <literal>0</literal>, busy handlers will be disabled and sqlite will return immediately with a <literal>SQLITE_BUSY</literal> status code if another process/thread has the database locked for an update. </para> <para> PHP sets the default busy timeout to be 60 seconds when the database is opened. </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-changes.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-changes.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-changes"> <refnamediv> <refname>sqlite_changes</refname> <refpurpose>Returns the number of rows that were changed by the most recent SQL statement</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>int</type><function>sqlite_changes</function> <methodparam><type>resource</type><parameter>db</parameter></methodparam> </methodsynopsis> <para> Returns the numbers of rows that were changed by the most recent SQL statement executed against the database <parameter>db</parameter>. </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-close.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-close.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-close"> <refnamediv> <refname>sqlite_close</refname> <refpurpose>Closes an open SQLite database.</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>void</type><function>sqlite_close</function> <methodparam><type>resource</type><parameter>database</parameter></methodparam> </methodsynopsis> <para> Closes the given <parameter>database</parameter> handle. If the database was persistent, it will be closed and removed from the persistent list. </para> <para> See also <function>sqlite_open</function> and <function>sqlite_popen</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-column.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-column.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-column"> <refnamediv> <refname>sqlite_column</refname> <refpurpose>Fetches a column from the current row of a result set</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>mixed</type><function>sqlite_column</function> <methodparam><type>resource</type><parameter>result</parameter></methodparam> <methodparam><type>mixed</type><parameter>index_or_name</parameter></methodparam> <methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter></methodparam> </methodsynopsis> <para> Fetches the value of a column named <parameter>index_or_name</parameter> (if it is a string), or of the ordinal column numbered <parameter>index_or_name</parameter> (if it is an integer) from the current row of the query result handle <parameter>result</parameter>. The decode binary flag operates in the same way as described under <function>sqlite_fetch_array</function>. </para> <para> Use this function when you are iterating a large result set with many columns, or with columns that contain large amounts of data. </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-create-function.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-create-function.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-create-function"> <refnamediv> <refname>sqlite_create_function</refname> <refpurpose>Registers a "regular" User Defined Function for use in SQL statements</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><function>sqlite_create_function</function> <methodparam><type>resource</type><parameter>db</parameter></methodparam> <methodparam><type>string</type><parameter>function_name</parameter></methodparam> <methodparam><type>mixed</type><parameter>callback</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>num_args</parameter></methodparam> </methodsynopsis> <para> <function>sqlite_create_function</function> allows you to register a PHP function with SQLite as an <acronym>UDF</acronym> (User Defined Function), so that it can be called from within your SQL statements. </para> <para> <parameter>db</parameter> specifies the database handle that you wish to extend, <parameter>function_name</parameter> specifies the name of the function that you will use in your SQL statements, <parameter>callback</parameter> is any valid PHP callback to specify a PHP function that should be called to handle the SQL function. The optional parameter <parameter>num_args</parameter> is used as a hint by the SQLite expression parser/evaluator. It is recommended that you specifiy a value if your function will only ever accept a fixed number of parameters. </para> <para> The UDF can be used in any SQL statement that can call functions, such as SELECT and UPDATE statements and also in triggers. </para> <example> <title><function>sqlite_create_function</function> example</title> <programlisting role="php"> <![CDATA[ <?php function md5_and_reverse($string) { return strrev(md5($string)); } sqlite_create_function($db, 'md5rev', 'md5_and_reverse', 1); $rows = sqlite_array_query($db, 'SELECT md5rev(filename) from files'); ?>]]> </programlisting> <para> In this example, we have a function that calculates the md5 sum of a string, and then reverses it. When the SQL statement executes, it returns the value of the filename transformed by our function. The data returned in <parameter>$rows</parameter> contains the processed result. </para> <para> The beauty of this technique is that you do not need to process the result using a foreach() loop after you have queried for the data. </para> </example> <note> <para> PHP registers a special function named <literal>php</literal> when the database is first opened. The php function can be used to call any PHP function without having to register it first. </para> </note> <example> <title>Example of using the PHP function</title> <programlisting role="php"> <![CDATA[ <?php $rows = sqlite_array_query($db, "SELECT php('md5', filename) from files"); ?>]]> </programlisting> <para> This example will call the <function>md5</function> on each <literal>filename</literal> column in the database and return the result into <parameter>$rows</parameter> </para> </example> <note> <para> For performance reasons, PHP will not automatically encode/decode binary data passed to and from your UDF's. You need to manually encode/decode the parameters and return values if you need to process binary data in this way. </para> <para> <emphasis>It is not recommended to use UDF's to handle processesing of binary data, unless high performance is not a key requirement of your application. </emphasis> </para> </note> <para> See also <function>sqlite_register_aggregate</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-current.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-current.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-current"> <refnamediv> <refname>sqlite_current</refname> <refpurpose>Fetches the current row from a result set as an array</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>array</type><methodname>sqlite_current</methodname> <methodparam><type>resource</type><parameter>result</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> <function>sqlite_current</function> is identical to <function>sqlite_fetch_array</function> except that it does not advance to the next row prior to returning the data; it returns the data from the current position only. </para> <para> If the current position is beyond the final row, this function returns &false; </para> <note> <para> This function will not work on unbuffered result handles. </para> </note> <para> See also <function>sqlite_seek</function>, <function>sqlite_next</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-error-string.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-error-string.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-error-string"> <refnamediv> <refname>sqlite_error_string</refname> <refpurpose>Returns the textual description of an error code</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>string</type><methodname>sqlite_error_string</methodname> <methodparam><type>int</type><parameter>error_code</parameter></methodparam> </methodsynopsis> <para> Returns a human readable description of the <parameter>error_code</parameter> returned from <function>sqlite_last_error</function>. </para> <para> See also <function>sqlite_last_error</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-escape-string.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-escape-string.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-escape-string"> <refnamediv> <refname>sqlite_escape_string</refname> <refpurpose>Escapes a string for use as a query parameter</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>string</type><methodname>sqlite_escape_string</methodname> <methodparam><type>string</type><parameter>item</parameter></methodparam> </methodsynopsis> <para> <function>sqlite_escape_string</function> will correctly quote the string specified by <parameter>item</parameter> for use in an SQLite SQL statement. This includes doubling up single-quote characters (<literal>'</literal>) and checking for binary-unsafe characters in the query string. </para> <para> If the <parameter>item</parameter> contains a <literal>NUL</literal> character, or if it begins with a character whose ordinal value is <literal>0x01</literal>, PHP will apply a binary encoding scheme so that you can safely store and retrieve binary data. </para> <para> Although the encoding makes it safe to insert the data, it will render simple text comparisions and LIKE clauses in your queries unusable for the columns that contain the binary data. In practice, this shouldn't be a problem, as your schema should be such that you don't use such things on binary columns (in fact, it might be better to store binary data using other means, such as in files). </para> <warning> <simpara> <function>addslashes</function> should <emphasis>NOT</emphasis> be used to quote your strings for SQLite queries; it will lead to strange results when retrieving your data. </simpara> </warning> </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-fetch-array.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-fetch-array.xml <?xml version="1.0" encoding="iso-8859-1"?> <refentry id="function.sqlite-fetch-array"> <refnamediv> <refname>sqlite_fetch_array</refname> <refpurpose>Fetches the next row from a result set as an array.</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>array</type><methodname>sqlite_fetch_array</methodname> <methodparam><type>resource</type><parameter>result</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> Fetches the next row from the given <parameter>result</parameter> handle. If there are no more rows, returns &false;, otherwise returns an associative array representing the row data. </para> <para> <parameter>result_type</parameter> can be used to specifiy how you want the results to be returned. The default value is <literal>SQLITE_BOTH</literal> which returns columns indexed by their ordinal column number and by column name. <literal>SQLITE_ASSOC</literal> causes the array to be indexed only by column names, and <literal>SQLITE_NUM</literal> to be indexed only by ordinal column numbers. </para> <para> The column names returned by <literal>SQLITE_ASSOC</literal> and <literal>SQLITE_BOTH</literal> will be case-folded according to the value of the <link linkend="ini.sqlite.assoc-case">sqlite.assoc_case</link> configuration option. </para> <para> When <parameter>decode_binary</parameter> is set to &true; (the default), PHP will decode the binary encoding it applied to the data if it was encoded using the <function>sqlite_escape_string</function>. You will usually always leave this value at its default, unless you are interoperating with databases created by other sqlite capable applications. </para> <para> See also <function>sqlite_array_query</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-fetch-string.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-fetch-string.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-fetch-string"> <refnamediv> <refname>sqlite_fetch_string</refname> <refpurpose>Fetches first column of a result set as a string.</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>string</type><methodname>sqlite_fetch_string</methodname> <methodparam><type>resource</type><parameter>result</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> <function>sqlite_fetch_string</function> is identical to <function>sqlite_fetch_array</function> except that it returns the value of the first column of the rowset. </para> <para> This is the most optimial way to retrieve data when you are only interested in the values from a single column of data. </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-field-name.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-field-name.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-field-name"> <refnamediv> <refname>sqlite_field_name</refname> <refpurpose>Returns the name of a particular field</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>string</type><methodname>sqlite_field_name</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> <methodparam><type>int</type><parameter>field_index</parameter></methodparam> </methodsynopsis> <para> Given the ordinal column number, <literal>field_index</literal>, returns the name of that field in the result handle <parameter>result</parameter>. </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-has-more.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-has-more.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-has-more"> <refnamediv> <refname>sqlite_has_more</refname> <refpurpose>Returns whether or not more rows are available</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><methodname>sqlite_has_more</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> </methodsynopsis> <para> <function>sqlite_has_more</function> returns &true; if there are more rows available from the <parameter>result</parameter> handle, or &false; otherwise. </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-last-error.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-last-error.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-last-error"> <refnamediv> <refname>sqlite_last_error</refname> <refpurpose>Returns the error code of the last error for a database</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>int</type><methodname>sqlite_last_error</methodname> <methodparam><type>resource</type><parameter>db</parameter></methodparam> </methodsynopsis> <para> Returns the error code from the last operation performed on <parameter>db</parameter>, the database handle. </para> <para> See also <function>sqlite_error_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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-last-insert-rowid.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-last-insert-rowid.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-last-insert-rowid"> <refnamediv> <refname>sqlite_last_insert_rowid</refname> <refpurpose>Returns the rowid of the most recently inserted row</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>int</type><methodname>sqlite_last_insert_rowid</methodname> <methodparam><type>resource</type><parameter>db</parameter></methodparam> </methodsynopsis> <para> Returns the rowid of the row that was most recently inserted into the database <parameter>db</parameter>, if it was created as an auto-increment field. </para> <note> <para> You can create auto-increment fields in SQLite by declaring them as <literal>INTEGER PRIMARY KEY</literal> in your table schema. </para> </note> </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-libencoding.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-libencoding.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-libencoding"> <refnamediv> <refname>sqlite_libencoding</refname> <refpurpose>Returns the encoding of the linked SQLite library </refpurpose></refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>string</type><methodname>sqlite_libencoding</methodname> </methodsynopsis> <para> The SQLite library may be compiled in either ISO-8859-1 or UTF-8 compatible modes. This function allows you to determine which encoding scheme is used by your version of the library. </para> <note> <para> The default PHP distribution builds libsqlite in ISO-8859-1 encoding mode. However, this is a misnomer; rather than handling ISO-8859-1, it operates according to your current locale settings for string comparisons and sort ordering. So, rather than ISO-8859-1, you should think of it as being '8-bit' instead. </para> <para> When compiled with UTF-8 support, sqlite handles encoding and decoding of UTF-8 multi-byte character sequences, but does not yet do a complete job when working with the data (no normalization is performed for example), and some comparison operations may still not be carried out correctly. </para> <para> It is not recommended that you use PHP in a web-server configuration with a version of the SQLite library compiled with UTF-8 support, since libsqlite will abort() the process if it detects a problem with the UTF-8 encoding. </para> </note> <para> See also <function>sqlite_libversion</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-libversion.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-libversion.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-libversion"> <refnamediv> <refname>sqlite_libversion</refname> <refpurpose>Returns the version of the linked SQLite library</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>string</type><methodname>sqlite_libencoding</methodname> </methodsynopsis> <para> Returns the version of the linked SQLite library as a string. </para> <para> See also <function>sqlite_libencoding</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-next.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-next.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-next"> <refnamediv> <refname>sqlite_next</refname> <refpurpose>Seek to next row number</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><methodname>sqlite_next</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> </methodsynopsis> <para> <function>sqlite_next</function> advances the result handle <parameter>result</parameter> to the next row. Returns &false; if there are no more rows, &true; otherwise. </para> <note> <para> This function cannot be used with unbuffered result handles. </para> </note> <para> See also <function>sqlite_seek</function>, <function>sqlite_current</function> and <function>sqlite_rewind</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-num-fields.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-num-fields.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-num-fields"> <refnamediv> <refname>sqlite_num_fields</refname> <refpurpose>Returns the number of fields in a result set</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>int</type><methodname>sqlite_num_fields</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> </methodsynopsis> <para> Returns the number of fields in the <parameter>result</parameter> set. </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-num-rows.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-num-rows.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-num-rows"> <refnamediv> <refname>sqlite_num_rows</refname> <refpurpose>Returns the number of rows in a result set</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>int</type><methodname>sqlite_num_rows</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> </methodsynopsis> <para> Returns the number of rows in the <parameter>result</parameter> set. </para> <note> <para> This function cannot be used with unbuffered result sets. </para> </note> </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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-open.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-open.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-open"> <refnamediv> <refname>sqlite_open</refname> <refpurpose>Opens a SQLite database. Will create the database if it does not exist</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>resource</type><methodname>sqlite_open</methodname> <methodparam><type>string</type><parameter>filename</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>mode</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>&errmessage</parameter></methodparam> </methodsynopsis> <para> Returns a resource on success, &false; on error. </para> <para> The <parameter>filename</parameter> parameter is the name of the database. It can be a relative or absolute path to the file that sqlite will use to store your data. If the file does not exist, sqlite will attempt to create it. You <emphasis>MUST</emphasis> have write permissions to the file if you want to insert data or modify the database schema. </para> <para> The <parameter>mode</parameter> parameter specifies the mode of the file and is intended to be used to open the database in read-only mode. Presently, this parameter is ignored by the sqlite library. The default value for mode is the octal value <literal>0666</literal> and this is the recommended value to use if you need access to the <parameter>errmessage</parameter> parameter. </para> <para> <parameter>errmessage</parameter> is passed by reference and is set to hold a descriptive error message explaining why the database could not be opened if there was an error. </para> <example> <title><function>sqlite_open</function> example</title> <programlisting role="php"> <![CDATA[ <?php if ($db=sqlite_open('mysqlitedb', 0666, $sqliteerror)) { sqlite_query('CREATE TABLE foo (bar varchar(10))'); sqlite_query("INSERT INTO foo VALUES ('fnord')"); $result=sqlite_query('select bar from foo'); var_dump(sqlite_fetch_array($result)); } else { die($sqliteerror); } ?>]]> </programlisting> </example> <note> <simpara> On Unix platforms, SQLite is sensitive to scripts that use the fork() system call. If you do have such a script, it is recommended that you close the handle prior to forking and then re-open it in the child and/or parent. For more information on this issue, see <ulink url="http://www.sqlite.org/c_interface.html">The C language interface to the SQLite library</ulink> in the section entitled <literal>Multi-Threading And SQLite</literal>. </simpara> </note> <note> <simpara> Starting with SQLite library version 2.8.2, you can specify <literal>:memory:</literal> as the <parameter>filename</parameter> to create a database that lives only in the memory of the computer. This is useful mostly for temporary processing, as the in-memory database will be destroyed when the process ends. It can also be useful when coupled with the <literal>ATTACH DATABASE</literal> SQL statement to load other databases and move and query data betweem them. </simpara> </note> <note> <simpara> SQLite is safe_mode and open_basedir aware. </simpara> </note> <para> See also <function>sqlite_popen</function>, <function>sqlite_close</function> and <function>sqlite_query</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-popen.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-popen.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-popen"> <refnamediv> <refname>sqlite_popen</refname> <refpurpose>Opens a persistent handle to an SQLite database. Will create the database if it does not exist</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>resource</type><methodname>sqlite_popen</methodname> <methodparam><type>string</type><parameter>filename</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>mode</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>&errmessage</parameter></methodparam> </methodsynopsis> <note> <simpara> This function behaves identically to <function>sqlite_open</function> except that is uses the persistent resource mechanism of PHP. For information about the meaning of the parameters, read the <function>sqlite_open</function> manual page. </simpara> </note> <para> <function>sqlite_popen</function> will first check to see if a persistent handle has already been opened for the given <parameter>filename</parameter>. If it finds one, it returns that handle to your script, otherwise it opens a fresh handle to the database. </para> <para> The benefit of this approach is that you don't incurr the performance cost of re-reading the database and index schema on each page hit served by persistent web server SAPI's (any SAPI except for regular CGI or CLI). </para> <note> <simpara> If you use persistent handles and have the database updated by a background process (perhaps via a crontab), and that process re-creates the database by overwriting it (either by unlinking and rebuilding, or moving the updated version to replace the current version), you may experience undefined behaviour when a persistent handle on the old version of the database is recycled. </simpara> <simpara> To avoid this situation, have your background processes open the same database file and perform their updates in a transaction. </simpara> </note> <para> See also <function>sqlite_popen</function>, <function>sqlite_close</function> and <function>sqlite_query</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-query.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-query.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-query"> <refnamediv> <refname>sqlite_query</refname> <refpurpose>Executes a query against a given database and returns a result handle</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>resource</type><methodname>sqlite_query</methodname> <methodparam><type>resource</type><parameter>db</parameter></methodparam> <methodparam><type>string</type><parameter>query</parameter></methodparam> </methodsynopsis> <methodsynopsis> <type>resource</type><methodname>sqlite_query</methodname> <methodparam><type>string</type><parameter>query</parameter></methodparam> <methodparam><type>resource</type><parameter>db</parameter></methodparam> </methodsynopsis> <para> Executes an SQL statement given by the <parameter>query</parameter> against a given database (specified by the <parameter>db</parameter> parameter). </para> <para> For queries that return rows, this function will return a result handle which can then be used with functions such as <function>sqlite_fetch_array</function> and <function>sqlite_seek</function>. </para> <para> For other kinds of queries, this function will return a boolean result; &true; for success or &false; for failure. </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> <note> <simpara> Two alternative syntaxes are supported for compatibility with other database extensions (such as MySQL). The preferred form is the first one, where the <parameter>db</parameter> parameter is the first parameter to the function. </simpara> </note> <note> <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 loaded from a file or have embedded in a script. </simpara> <simpara> When executing multiple queries, the return value of this function will be &false; if the was an error, but undefined otherwise (it might be &true; for success or it might return a result handle). </simpara> </note> <para> See also <function>sqlite_array_query</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-register-aggregate.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-register-aggregate.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-register-aggregate"> <refnamediv> <refname>sqlite_register_aggregate</refname> <refpurpose>Register an aggregating UDF for use in SQL statements</refpurpose></refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><function>sqlite_register_aggregate</function> <methodparam><type>resource</type><parameter>db</parameter></methodparam> <methodparam><type>string</type><parameter>function_name</parameter></methodparam> <methodparam><type>mixed</type><parameter>step_func</parameter></methodparam> <methodparam><type>mixed</type><parameter>finalize_func</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>num_args</parameter></methodparam> </methodsynopsis> <para> <function>sqlite_register_aggregate</function> is similar to <function>sqlite_create_function</function> except that it registers functions that can be used to calculate a result aggregated across all the rows of a query. </para> <para> The key difference between this function and <function>sqlite_create_function</function> is that two functions are required to manage the aggregate; <parameter>step_func</parameter> is called for each row of the result set. Your PHP function should accumulate the result and store it into the aggregation context. Once all the rows have been processed, <parameter>finalize_func</parameter> will be called and it should then take the data from the aggregation context and return the result. </para> <example> <title>max_length aggregation function example</title> <programlisting role="php"> <![CDATA[ <?php $data = array( 'one', 'two', 'three', 'four' 'five' 'six', 'seven', 'eight', 'nine' 'ten' ); $db = sqlite_open(':memory:'); sqlite_query($db, "CREATE TABLE strings(a)"); foreach ($data as $str) { sqlite_query($db, "INSERT INTO strings VALUES('" . sqlite_escape_string($str) . "')"); } function max_len_step(&$context, $string) { if (strlen($string) > $context) { $context = strlen($string); } } function max_len_finalize(&$context) { return $context; } sqlite_create_aggregate($db, 'max_len', 'max_len_step', 'max_len_finalize'); var_dump(sqlite_array_query($db, 'SELECT max_len(a) from strings')); ?>]]> </programlisting> <para> In this example, we are creating an aggregating function that will calculate the length of the longest string in one of the columns of the table. For each row, the <literal>max_len_step</literal> function is called and passed a <parameter>context</parameter> parameter. The context parameter is just like any other PHP variable and be set to hold an array or even an object value. In this example, we are simply using it to hold the maximum length we have seen so far; if the <parameter>string</parameter> has a length longer than the current maximum, we update the the context to hold this new maximum length. </para> <para> After all of the rows have been processed, SQLite calls the <literal>max_len_finalize</literal> function to determine the aggregate result. Here, we could perform some kind of calculation based on the data found in the <parameter>context</parameter>. In our simple example though, we have been calculating the result as the query progressed, so we simply need to return the context value. </para> </example> <note> <para> It is NOT recommended for you to store a copy of the values in the context and then process them at the end, as you would cause SQLite to use a lot of memory to process the query - just think of how much memory you would need if a million rows were stored in memory, each containing a string 32 bytes in length. </para> </note> <para> See also <function>sqlite_create_function</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-rewind.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-rewind.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-rewind"> <refnamediv> <refname>sqlite_rewind</refname> <refpurpose>Seek to the first row number</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><methodname>sqlite_rewind</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> </methodsynopsis> <para> <function>sqlite_rewind</function> seeks back to the first row in the result set. Returns &false; if there are no rows in the result set, &true; otherwise. </para> <note> <para> This function cannot be used with unbuffered result sets. </para> </note> <para> See also <function>sqlite_next</function>, <function>sqlite_current</function> and <function>sqlite_seek</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-seek.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-seek.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-seek"> <refnamediv> <refname>sqlite_seek</refname> <refpurpose>Seek to a particular row number</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><methodname>sqlite_rewind</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> <methodparam><type>int</type><parameter>rownum</parameter></methodparam> </methodsynopsis> <para> <function>sqlite_seek</function> seeks to the row given by the parameter <parameter>rownum</parameter>. The row number is one-based (1 is the first row). Returns &false; if the row does not exist, &true; otherwise. </para> <note> <para> This function cannot be used with unbuffered result handles. </para> </note> <para> See also <function>sqlite_next</function>, <function>sqlite_current</function> and <function>sqlite_rewind</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 --> Index: phpdoc/en/reference/sqlite/functions/sqlite-unbuffered-query.xml +++ phpdoc/en/reference/sqlite/functions/sqlite-unbuffered-query.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.sqlite-unbuffered-query"> <refnamediv> <refname>sqlite_unbuffered_query</refname> <refpurpose>Execute a query that does not prefetch and buffer all data</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>resource</type><methodname>sqlite_unbuffered_query</methodname> <methodparam><type>resource</type><parameter>db</parameter></methodparam> <methodparam><type>string</type><parameter>query</parameter></methodparam> </methodsynopsis> <methodsynopsis> <type>resource</type><methodname>sqlite_unbuffered_query</methodname> <methodparam><type>string</type><parameter>query</parameter></methodparam> <methodparam><type>resource</type><parameter>db</parameter></methodparam> </methodsynopsis> <para> <function>sqlite_unbuffered_query</function> is identical to <function>sqlite_query</function> except that the result that is returned is a sequential forward-only result set that can only be used to read each row, one after the other. </para> <para> This function is ideal for generating things such as HTML tables where you only need to process one row at a time and don't need to randomly access the row data. </para> <note> <para> Functions such as <function>sqlite_seek</function> and <function>sqlite_rewind</function> do not work on result handles returned from this function. </para> </note> </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 -->
-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php