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-popen.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-popen.php',
   
1 => 'sqlite_popen',
  ),
 
'up' =>
  array (
   
0 => 'ref.sqlite.php',
   
1 => 'SQLite Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.sqlite-open.php',
   
1 => 'sqlite_open',
  ),
 
'next' =>
  array (
   
0 => 'function.sqlite-prev.php',
   
1 => 'sqlite_prev',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.sqlite-popen" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sqlite_popen</h1>
  <p class="verinfo">(PHP 5, PECL sqlite &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">sqlite_popen</span> &mdash; <span class="dc-title">
   Opens a persistent handle to an SQLite database and create the database if it does not exist
  </span></p>

 </div>

 <a name="function.sqlite-popen.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><b>sqlite_popen</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="simpara">
   This function behaves identically to <a href="function.sqlite-open.php" class="function">sqlite_open()</a>
   except that is uses the persistent resource mechanism of PHP.
   For information about the meaning of the parameters, read the
   <a href="function.sqlite-open.php" class="function">sqlite_open()</a> manual page.
  </p>
  <p class="para">
   <b>sqlite_popen()</b> will first check to see if a persistent
   handle has already been opened for the given
   <i><tt class="parameter">filename</tt></i>
.  If it finds one, it returns that handle
   to your script, otherwise it opens a fresh handle to the database.
  </p>
  <p class="para">
   The benefit of this approach is that you don&#039;t incur the performance
   cost of re-reading the database and index schema on each page hit served
   by persistent web server SAPI&#039;s (any SAPI except for regular CGI or CLI).
  </p>
  <blockquote><p><b class="note">Note</b>:
   <span class="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.
   </span>
   <span class="simpara">
    To avoid this situation, have your background processes open the same
    database file and perform their updates in a transaction.
   </span>
  </p></blockquote>
 </div>


 <a name="function.sqlite-popen.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.  If the file does not exist, SQLite
       will attempt to create it.  PHP must have write permissions to the file
       if data is inserted, the database schema is modified or to create the
       database if it does not exist.
      </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-popen.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a resource (database handle) on success, <b><tt class="constant">FALSE</tt></b> on error.
  </p>
 </div>


 <a name="function.sqlite-popen.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-close.php" class="function" rel="rdfs-seeAlso">sqlite_close()</a> - Closes an open SQLite database</li>
    <li class="member"><a href="function.sqlite-factory.php" class="function" rel="rdfs-seeAlso">sqlite_factory()</a> - Opens a SQLite database and returns a SQLiteDatabase object</li>
   </ul><p>
  </p>
 </div>

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