<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<refentry id="function.sqlite-factory">
 <refnamediv>
  <refname>sqlite_factory</refname>
  <refpurpose>Opens a SQLite database and returns a SQLiteDatabase object</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>SQLiteDatabase</type><methodname>sqlite_factory</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 role="reference">error_message</parameter></methodparam>
  </methodsynopsis>
  <para>
   <function>sqlite_factory</function> behaves similarly to
   <function>sqlite_open</function> in that it opens an SQLite database or
   attempts to create it if it does not exist.  However, a
   <link linkend="sqlite.class.sqlitedatabase">SQLiteDatabase</link> object is
   returned rather than a resource.  Please see the
   <function>sqlite_open</function> reference page for further usage and caveats.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>filename</parameter></term>
     <listitem>
      <para>
       The filename of the SQLite database.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>mode</parameter></term>
     <listitem>
      <para>
       The mode of the file. 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.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>error_message</parameter></term>
     <listitem>
      <para>
       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>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns a SQLiteDatabase object on success, &null; on error.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>sqlite_factory</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$dbhandle = sqlite_factory('sqlitedb');
$dbhandle->query('SELECT user_id, username FROM users');

/* functionally equivalent to: */

$dbhandle = new SQLiteDatabase('sqlitedb');
$dbhandle->query('SELECT user_id, username FROM users');

?>]]>
    </programlisting>
   </example>
  </para>
 </refsect1>
 
 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>sqlite_open</function></member>
    <member><function>sqlite_popen</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:"../../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
 -->