<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Connecting to SQLite databases</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-sqlite.html">SQLite (PDO)</a></div> <div class="next" style="text-align: right; float: right;"><a href="pdo.sqlitecreateaggregate.html">PDO::sqliteCreateAggregate</a></div> <div class="up"><a href="ref.pdo-sqlite.html">SQLite (PDO)</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="ref.pdo-sqlite.connection" class="refentry"> <div class="refnamediv"> <h1 class="refname">PDO_SQLITE DSN</h1> <p class="verinfo">(PECL PDO_SQLITE >= 0.2.0)</p><p class="refpurpose"><span class="refname">PDO_SQLITE DSN</span> — <span class="dc-title">Connecting to SQLite databases</span></p> </div> <div class="refsect1 description" id="refsect1-ref.pdo-sqlite.connection-description"> <h3 class="title">Description</h3> <p class="para"> The PDO_SQLITE Data Source Name (DSN) is composed of the following elements: <dl> <dt> <span class="term">DSN prefix (SQLite 3)</span> <dd> <p class="para"> The DSN prefix is <strong class="userinput"><code>sqlite:</code></strong>. <ul class="itemizedlist"> <li class="listitem"> <p class="para"> To access a database on disk, append the absolute path to the DSN prefix. </p> </li> <li class="listitem"> <p class="para"> To create a database in memory, append <em>:memory:</em> to the DSN prefix. </p> </li> </ul> </p> </dd> </dt> <dt> <span class="term">DSN prefix (SQLite 2)</span> <dd> <p class="para"> The <a href="ref.sqlite.html" class="link">SQLite</a> extension in PHP 5.1 provides a PDO driver that supports accessing and creating SQLite 2 databases. This enables you to access databases you may have created with the <a href="ref.sqlite.html" class="link">SQLite</a> extension in previous versions of PHP. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> The sqlite2 driver is only available in PHP 5.1.x if you have enabled both PDO and ext/sqlite. It is not currently available via PECL. </p> </p></blockquote> <p class="para"> The DSN prefix for connecting to SQLite 2 databases is <strong class="userinput"><code>sqlite2:</code></strong>. <ul class="itemizedlist"> <li class="listitem"> <p class="para"> To access a database on disk, append the absolute path to the DSN prefix. </p> </li> <li class="listitem"> <p class="para"> To create a database in memory, append <em>:memory:</em> to the DSN prefix. </p> </li> </ul> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 examples" id="refsect1-ref.pdo-sqlite.connection-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-989"> <p><strong>Example #1 PDO_SQLITE DSN examples</strong></p> <div class="example-contents"><p> The following examples show PDO_SQLITE DSN for connecting to SQLite databases: <div class="example-contents"> <div class="cdata"><pre> sqlite:/opt/databases/mydb.sq3 sqlite::memory: sqlite2:/opt/databases/mydb.sq2 sqlite2::memory: </pre></div> </div> </p></div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-sqlite.html">SQLite (PDO)</a></div> <div class="next" style="text-align: right; float: right;"><a href="pdo.sqlitecreateaggregate.html">PDO::sqliteCreateAggregate</a></div> <div class="up"><a href="ref.pdo-sqlite.html">SQLite (PDO)</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>