downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.sqlite-factory.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.sqlite.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.sqlite-factory.php',
   
1 => 'sqlite_factory',
  ),
 
'up' =>
  array (
   
0 => 'ref.sqlite.php',
   
1 => 'SQLite Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.sqlite-exec.php',
   
1 => 'sqlite_exec',
  ),
 
'next' =>
  array (
   
0 => 'function.sqlite-fetch-all.php',
   
1 => 'sqlite_fetch_all',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.sqlite-factory" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sqlite_factory</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">sqlite_factory</span> &mdash; <span class="dc-title">Opens a SQLite database and returns a SQLiteDatabase object</span></p>

 </div>

 <a name="function.sqlite-factory.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type SQLiteDatabase">SQLiteDatabase</span></span> <span class="methodname"><b>sqlite_factory</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$filename</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$mode</tt><span class="initializer"> = 0666</span></span>
   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter reference">&amp;$error_message</tt></span>
  ]] )</div>

  <p class="para rdfs-comment">
   <b>sqlite_factory()</b> behaves similarly to
   <a href="function.sqlite-open.php" class="function">sqlite_open()</a> in that it opens an SQLite database or
   attempts to create it if it does not exist.  However, a
   <a href="ref.sqlite.php#sqlite.class.sqlitedatabase" class="link">SQLiteDatabase</a> object is
   returned rather than a resource.  Please see the
   <a href="function.sqlite-open.php" class="function">sqlite_open()</a> reference page for further usage and caveats.
  </p>
 </div>


 <a name="function.sqlite-factory.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">filename</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The filename of the SQLite database.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">mode</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="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
       <i>0666</i> and this is the recommended value.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">error_message</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="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.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.sqlite-factory.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a SQLiteDatabase object on success, <b><tt class="constant">NULL</tt></b> on error.
  </p>
 </div>


 <a name="function.sqlite-factory.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>sqlite_factory()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$dbhandle&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlite_factory</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlitedb'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$dbhandle</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT&nbsp;user_id,&nbsp;username&nbsp;FROM&nbsp;users'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;functionally&nbsp;equivalent&nbsp;to:&nbsp;*/<br /><br /></span><span style="color: #0000BB">$dbhandle&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SQLiteDatabase</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlitedb'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$dbhandle</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT&nbsp;user_id,&nbsp;username&nbsp;FROM&nbsp;users'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>

 
 <a name="function.sqlite-factory.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.sqlite-open.php" class="function" rel="rdfs-seeAlso">sqlite_open()</a> - Opens a SQLite database and create the database if it does not exist</li>
    <li class="member"><a href="function.sqlite-popen.php" class="function" rel="rdfs-seeAlso">sqlite_popen()</a> - Opens a persistent handle to an SQLite database and create the database if it does not exist</li>
   </ul><p>
  </p>
 </div>

</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites