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

search for in the

SQLite3::createAggregate> <SQLite3::close
[edit] Last updated: Fri, 25 May 2012

view this page in

SQLite3::__construct

(PHP 5 >= 5.3.0)

SQLite3::__construct SQLite3 オブジェクトを作成し、SQLite 3 データベースをオープンする

説明

public SQLite3::__construct ( string $filename [, int $flags [, string $encryption_key ]] )

SQLite3 オブジェクトを作成し、SQLite 3 データベースをオープンします。 暗号化込みでビルドされている場合は、キーの使用を試みます。

パラメータ

filename

SQLite データベースへのパス。インメモリデータベースを使う場合は :memory: を指定します。

flags

SQLite データベースのオープン方法を指定するフラグ。 デフォルトでは SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE を使用してオープンします。

  • SQLITE3_OPEN_READONLY: データベースを読み込み専用でオープンする

  • SQLITE3_OPEN_READWRITE: データベースを読み書き共用でオープンする

  • SQLITE3_OPEN_CREATE: データベースが存在しない場合は作成する

encryption_key

オプションの暗号キー。SQLite データベースの暗号化と復号に使用します。

返り値

成功した場合に SQLite3 オブジェクトを返します。

例1 SQLite3::__construct() の例

<?php
$db 
= new SQLite3('mysqlitedb.db');

$db->exec('CREATE TABLE foo (bar STRING)');
$db->exec("INSERT INTO foo (bar) VALUES ('This is a test')");

$result $db->query('SELECT bar FROM foo');
var_dump($result->fetchArray());
?>



SQLite3::createAggregate> <SQLite3::close
[edit] Last updated: Fri, 25 May 2012
 
add a note add a note User Contributed Notes SQLite3::__construct
Anonymous 28-Apr-2012 05:32
Construct will fail if \ backslash is used in the database path,
use / forward slash instead for directory separators.
anton dot grbin at carnet dot hr 17-Apr-2012 02:27
An exception will be thrown if __construct fails.

PHP Fatal error:  Uncaught exception 'Exception' with message 'Unable to open database: unable to open database file' in ...
bohwaz 16-May-2011 04:59
$encryption_key and all encryption features will be enabled only if the SQLite encryption module is installed. It's a proprietary, costly module. So if it's not present, supplying an encryption key will have absolutely no effect.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites