<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.sqlite3.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'sqlite3.construct.php',
    1 => 'SQLite3::__construct',
    2 => 'Instantiates an SQLite3 object and opens an SQLite 3 database',
  ),
  'up' => 
  array (
    0 => 'class.sqlite3.php',
    1 => 'SQLite3',
  ),
  'prev' => 
  array (
    0 => 'sqlite3.close.php',
    1 => 'SQLite3::close',
  ),
  'next' => 
  array (
    0 => 'sqlite3.createaggregate.php',
    1 => 'SQLite3::createAggregate',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/sqlite3/sqlite3/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="sqlite3.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SQLite3::__construct</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SQLite3::__construct</span> &mdash; <span class="dc-title">
   Instantiates an SQLite3 object and opens an SQLite 3 database
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-sqlite3.construct-description">
  <h3 class="title">Description</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SQLite3::__construct</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE</span></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$encryptionKey</code><span class="initializer"> = &quot;&quot;</span></span>)</div>

  <p class="para rdfs-comment">
   Instantiates an SQLite3 object and opens a connection to an
   SQLite 3 database. If the build includes encryption, then it will attempt
   to use the key.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-sqlite3.construct-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       Path to the SQLite database, or <code class="literal">:memory:</code> to use in-memory database.
       If <code class="parameter">filename</code> is an empty string, then a private, temporary on-disk
       database will be created. This private database will be automatically
       deleted as soon as the database connection is closed.
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       Optional flags used to determine how to open the SQLite database. By
       default, open uses <code class="literal">SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE</code>.
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          <strong><code><a href="sqlite3.constants.php#constant.sqlite3-open-readonly">SQLITE3_OPEN_READONLY</a></code></strong>: Open the database for
          reading only.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code><a href="sqlite3.constants.php#constant.sqlite3-open-readwrite">SQLITE3_OPEN_READWRITE</a></code></strong>: Open the database for
          reading and writing.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code><a href="sqlite3.constants.php#constant.sqlite3-open-create">SQLITE3_OPEN_CREATE</a></code></strong>: Create the database if it
          does not exist.
         </p>
        </li>
       </ul>
      </p>
     </dd>
    
    
     <dt><code class="parameter">encryptionKey</code></dt>
     <dd>
      <p class="para">
       An optional encryption key used when encrypting and decrypting an
       SQLite database. If the SQLite encryption module is not installed,
       this parameter will have no effect.
      </p>
     </dd>
    
   </dl>
  </p>

 </div>


 <div class="refsect1 errors" id="refsect1-sqlite3.construct-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Throws an <span class="classname"><a href="class.exception.php" class="classname">Exception</a></span> on failure.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-sqlite3.construct-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>7.0.10</td>
      <td>
       The <code class="parameter">filename</code> can now be empty to use a private,
       temporary on-disk database.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-sqlite3.construct-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>SQLite3::__construct()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$db </span><span style="color: #007700">= new </span><span style="color: #0000BB">SQLite3</span><span style="color: #007700">(</span><span style="color: #DD0000">'mysqlitedb.db'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exec</span><span style="color: #007700">(</span><span style="color: #DD0000">'CREATE TABLE foo (bar TEXT)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exec</span><span style="color: #007700">(</span><span style="color: #DD0000">"INSERT INTO foo (bar) VALUES ('This is a test')"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT bar FROM foo'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fetchArray</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


</div><?php manual_footer($setup); ?>