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

sqlite_open

(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0)
sqlite_open — Opens an SQLite database and create the database if it does not exist

说明

sqlite_open ( string $filename [, int $mode = 0666 [, string &$error_message ]] ) : resource

面向对象风格 (constructor):

final public SQLiteDatabase::__construct ( string $filename [, int $mode = 0666 [, string &$error_message ]] )

Opens an SQLite database or creates the database if it does not exist.
打开SQLite数据库或者创建数据库,如果它不存在。

参数

filename

The filename of the SQLite database. If the file does not exist, SQLite will attempt to create it. PHP must have write permissions to the file if data is inserted, the database schema is modified or to create the database if it does not exist.
这是文件名或者SQLite数据库。如果这个文件不存在,SQLIite将企图创建它。文件往这里插入,PHP必须有写权限,这个数据库模式计划修改或者创建数据库,如果它不存在。

mode

The mode of the file. Intended to be used to open the database in read-only mode. Presently, this parameter is ignored by the sqlite library. The default value for mode is the octal value 0666 and this is the recommended value.
文件模式。要以只读方式打开数据库。目前,这个参数可以忽略,在这个sqlite库中。模式是八进制的值,默认值是0666,并且这个是推荐使用的值。

error_message

Passed by reference and is set to hold a descriptive error message explaining why the database could not be opened if there was an error.
通过参考和设置,去保留描述性错误信息解释,为什么这个数据库不能打开,如果有一个错误。

返回值

Returns a resource (database handle) on success, FALSE on error.
返回一个资源(数据库句柄)表示成功,false表示错误。

范例

<?php
if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) { 
    sqlite_query($db, 'CREATE TABLE foo (bar varchar(10))');
    sqlite_query($db, "INSERT INTO foo VALUES ('fnord')");
    $result = sqlite_query($db, 'select bar from foo');
    var_dump(sqlite_fetch_array($result)); 
} else {
    die($sqliteerror);
}
?>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值