(PECL chdb >= 0.1.0)

chdb_createCreates a chdb file


bool chdb_create ( string $pathname , array $data )

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


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.

Elenco dei parametri


The name of the file to create.

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


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.

Valori restituiti

Restituisce TRUE in caso di successo, FALSE in caso di fallimento.


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


Example #1 chdb_create() example


= array(
'key1' => 'value1',
'key2' => 'value2',
// ...


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

add a note add a note

User Contributed Notes 1 note

jille at hexon dot cx
5 years ago
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:
('tmp.db', $data);
rename('tmp.db', 'database.db');
To Top