<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Creates a chdb file</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.chdb.html">chdb Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.curl.html">cURL</a></div> <div class="up"><a href="ref.chdb.html">chdb Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.chdb-create" class="refentry"> <div class="refnamediv"> <h1 class="refname">chdb_create</h1> <p class="verinfo">(PECL chdb >= 0.1.0)</p><p class="refpurpose"><span class="refname">chdb_create</span> — <span class="dc-title">Creates a chdb file</span></p> </div> <div class="refsect1 description" id="refsect1-function.chdb-create-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>chdb_create</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$pathname</code></span> , <span class="methodparam"><span class="type">array</span> <code class="parameter">$data</code></span> )</div> <p class="para rdfs-comment"> <span class="function"><strong>chdb_create()</strong></span> creates a chdb file containing the specified key-value pairs. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> 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. </p> </p></blockquote> </div> <div class="refsect1 parameters" id="refsect1-function.chdb-create-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <span class="term"><em><code class="parameter">pathname</code></em></span> <dd> <p class="para"> The name of the file to create. </p> <p class="para"> If a file with the same name already exists, it is overwritten. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">data</code></em></span> <dd> <p class="para"> An array containing the key-value pairs to store in the chdb file. </p> <p class="para"> 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. </p> </dd> </dt> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-function.chdb-create-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 errors" id="refsect1-function.chdb-create-errors"> <h3 class="title">Errors/Exceptions</h3> <p class="para"> Throws an exception in case the chdb file hasn't been successfully created. </p> </div> <div class="refsect1 examples" id="refsect1-function.chdb-create-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-4206"> <p><strong>Example #1 <span class="function"><strong>chdb_create()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$data </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">'key1' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'value1'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'key2' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'value2'</span><span style="color: #007700">,<br /> </span><span style="color: #FF8000">// ...<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">chdb_create</span><span style="color: #007700">(</span><span style="color: #DD0000">'data.chdb'</span><span style="color: #007700">, </span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p> The above example will generate a chdb file named <em>data.chdb</em> and containing the key-value pairs defined in <var class="varname"><var class="varname">$data</var></var>. </p></div> </div> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.chdb.html">chdb Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.curl.html">cURL</a></div> <div class="up"><a href="ref.chdb.html">chdb Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>