SQLite3::open
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
SQLite3::open — SQLite 데이터베이스를 엽니다.
설명
public SQLite3::open(string $filename
, int $flags
= SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, string $encryptionKey
= ""): void
SQLite 3 데이터베이스를 엽니다. 빌드에 암호화가 포함된 경우 키 사용을 시도합니다.
매개변수
filename
- SQLite 데이터베이스의 경로 또는 :memory: 인메모리 데이터베이스를 사용합니다.
flags
- SQLite 데이터베이스를 여는 방법을 결정하는 데 사용되는 선택적 플래그입니다. 기본적으로 열기는
SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE
.-
SQLITE3_OPEN_READONLY
: 읽기 전용 데이터베이스를 엽니다. -
SQLITE3_OPEN_READWRITE
: 읽고 쓰기 위해 데이터베이스를 엽니다. -
SQLITE3_OPEN_CREATE
: 데이터베이스가 없으면 생성합니다.
-
encryptionKey
- SQLite 데이터베이스를 암호화 및 해독할 때 사용되는 선택적 암호화 키입니다. SQLite 암호화 모듈이 설치되어 있지 않으면 이 매개변수는 효과가 없습니다.
반환 값
값이 반환되지 않습니다.
Examples
예제 #1 SQLite3::open() 예제
<?php
/**
* Simple example of extending the SQLite3 class and changing the __construct
* parameters, then using the open method to initialize the DB.
*/
class MyDB extends SQLite3
{
function __construct()
{
$this->open('mysqlitedb.db');
}
}
$db = new MyDB();
$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());
?>