总有人间一两风,填我十万八千梦

PHP chdb_create 用法 手册 | 示例代码

PHP开发手册 归档 627℃ 0评论

chdb_create

(PECL chdb >= 0.1.0)

chdb_createCreates a chdb file

说明

chdb_create ( string $pathname , array $data ) : bool

chdb_create() creates a chdb file containing the specified key-value pairs.

Note:

chdb files are not portable across little-endian and big-endian environments. Except for that, they are portable across different architectures. Also compatibility across different versions of chdb is not guaranteed.

参数

pathname

The name of the file to create.

If a file with the same name already exists, it is overwritten.

data

An array containing the key-value pairs to store in the chdb file.

Keys and values are converted to strings before being written to the file, as chdb only support the string type. Note that binary strings are supported as well, both as keys and values.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

错误/异常

Throws an exception in case the chdb file hasn't been successfully created.

范例

Example #1 chdb_create() example

<?php

$data = array(
    
'key1' => 'value1',
    
'key2' => 'value2',
    
// ...
);
chdb_create('data.chdb'$data);

?>

The above example will generate a chdb file named data.chdb and containing the key-value pairs defined in $data.

用户贡献的笔记

jille at hexon dot cx

Please keep in mind that you shouldn't write to a database that is being actively used. If another process is currently reading the database it might crash.

A safe way to update your database is:
<?php
chdb_create
('tmp.db', $data);
rename('tmp.db', 'database.db');
?>

转载请注明:悠然品鉴 » PHP chdb_create 用法 手册 | 示例代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址