PHP数据库扩展SQLite3的官方文档翻译

SQLite3::open

SQLite3::open — Opens an SQLite database
打开一个SQLite数据库

说明

public SQLite3::open ( string $filename [, int $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE [, string $encryption_key = "" ]] ) : void

Opens an SQLite 3 Database. If the build includes encryption, then it will attempt to use the key.
打开一个SQLite数据库,如果建立需要引入加密,那么它将企图使用这个秘钥。

参数

filename 文件名|数据库名

Path to the SQLite database, or :memory: to use in-memory database.
通往这个SQLite数据库的路径,或者内存去使用在内存中的数据库。

flags 标识

Optional flags used to determine how to open the SQLite database. By default, open uses SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE.
可选择标识用于决定如何打开SQLite数据库。默认,用SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE打开。

SQLITE3_OPEN_READONLY: Open the database for reading only.
SQLITE3_OPEN_READONLY: 打开数据库仅提供读。

SQLITE3_OPEN_READWRITE: Open the database for reading and writing.
SQLITE3_OPEN_READWRITE: 打开数据库提供读和写。

SQLITE3_OPEN_CREATE: Create the database if it does not exist.
SQLITE3_OPEN_CREATE: 创建数据库,如果它不存在。

encryption_key 秘钥

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.
一个可选的加密秘钥,在SQLite数据库中使用加密和解密。如果这个SQLite加密模块没有安装,这个参数将没有效果。

返回值

没有返回值。

范例
Example #1 SQLite3::open() example
<?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());
?>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值