uTools-Manuals/docs/php/px_create_fp.html
2019-04-28 19:00:34 +08:00

139 lines
9.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>Create a new paradox database</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.px-create-fp" class="refentry">
<div class="refnamediv">
<h1 class="refname">px_create_fp</h1>
<p class="verinfo">(PECL paradox &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">px_create_fp</span> &mdash; <span class="dc-title">Create a new paradox database</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.px-create-fp-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>px_create_fp</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$pxdoc</code></span>
, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$file</code></span>
, <span class="methodparam"><span class="type">array</span> <code class="parameter">$fielddesc</code></span>
) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
Create a new paradox database file. The actual file has to be opened before
with <span class="function"><a href="fopen.html" class="function">fopen()</a></span>. Make sure the file is writable.
</p>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">Calling this functions issues a warning about an empty tablename which
can be safely ignored. Just set the tablename afterwards with
<span class="function"><a href="px_set_parameter.html" class="function">px_set_parameter()</a></span>.</p>
</p></blockquote>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">This function is highly experimental, due to insufficient
documentation of the paradox file format. Database files created with this
function can be opened by <span class="function"><a href="px_open_fp.html" class="function">px_open_fp()</a></span> and has been
successfully opened by the Paradox software, but your milage may vary.
</p>
</p></blockquote>
</div>
<div class="refsect1 parameters" id="refsect1-function.px-create-fp-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">pxdoc</code></dt>
<dd>
<p class="para">
Resource identifier of the paradox database
as returned by <span class="function"><a href="px_new.html" class="function">px_new()</a></span>.
</p>
</dd>
<dt>
<code class="parameter">file</code></dt>
<dd>
<p class="para">File handle as returned by <span class="function"><a href="fopen.html" class="function">fopen()</a></span>.
</p>
</dd>
<dt>
<code class="parameter">fielddesc</code></dt>
<dd>
<p class="para">
<strong class="option unknown">fielddesc</strong>
is an array containing one element for each
field specification. A field specification is an array itself with
either two or three elements.The first element is always a string value
used as the name of the field. It may not be larger than ten
characters. The second element contains the field type which is one of
the constants listed in the table <a href="paradox.constants.html#paradox.table-fieldtypes" class="link">Constants for field types</a>.
In the case of a character field or bcd field, you will have to provide
a third element specifying the length respectively the precesion of the
field. If your field specification contains blob fields, you will have
to make sure to either make the field large enough for all field values
to fit or specify a blob file with
<span class="function"><a href="px_set_blob_file.html" class="function">px_set_blob_file()</a></span> for storing the blobs. If this is
not done the field data is truncated.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.px-create-fp-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.px-create-fp-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-2465">
<p><strong>Example #1 Creating a Paradox database with two fields</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if(!</span><span style="color: #0000BB">$pxdoc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">px_new</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Error&nbsp;handling&nbsp;*/<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">"test.db"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"w+"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fields&nbsp;</span><span style="color: #007700">=&nbsp;array(array(</span><span style="color: #DD0000">"col1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"S"</span><span style="color: #007700">),&nbsp;array(</span><span style="color: #DD0000">"col2"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"I"</span><span style="color: #007700">));<br />if(!</span><span style="color: #0000BB">px_create_fp</span><span style="color: #007700">(</span><span style="color: #0000BB">$pxdoc</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$fields</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Error&nbsp;handling&nbsp;*/<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">px_set_parameter</span><span style="color: #007700">(</span><span style="color: #0000BB">$pxdoc</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"tablename"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"testtable"</span><span style="color: #007700">);<br />for(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=-</span><span style="color: #0000BB">50</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">50</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$rec&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #0000BB">$i</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">$i</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">px_put_record</span><span style="color: #007700">(</span><span style="color: #0000BB">$pxdoc</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$rec</span><span style="color: #007700">);<br />}&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #0000BB">px_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$pxdoc</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">px_delete</span><span style="color: #007700">(</span><span style="color: #0000BB">$pxdoc</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.px-create-fp-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="px_new.html" class="function" rel="rdfs-seeAlso">px_new()</a> - Create a new paradox object</span></li>
<li class="member"><span class="function"><a href="px_put_record.html" class="function" rel="rdfs-seeAlso">px_put_record()</a> - Stores record into paradox database</span></li>
<li class="member"><span class="function"><a href="fopen.html" class="function" rel="rdfs-seeAlso">fopen()</a> - 打开文件或者 URL</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>