File: dbase.xml

package info (click to toggle)
phpdoc 20020310-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 35,272 kB
  • ctags: 354
  • sloc: xml: 799,767; php: 1,395; cpp: 500; makefile: 200; sh: 140; awk: 51
file content (415 lines) | stat: -rw-r--r-- 13,330 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.17 $ -->
 <reference id="ref.dbase">
  <title>dBase functions</title>
  <titleabbrev>dBase</titleabbrev>

  <partintro>
   <simpara>
    These functions allow you to access records stored in dBase-format
    (dbf) databases.  In order to use these functions, you must compile
    PHP with the <option role="configure">--enable-dbase</option> option.
   </simpara>
   <simpara>
    There is no support for indexes or memo fields. There is no
    support for locking, too. Two concurrent webserver processes
    modifying the same dBase file will very likely ruin your database.
   </simpara>
   <simpara>
    dBase files are simple sequential files of fixed
    length records. Records are appended to the end of
    the file and delete records are kept until you call
    <function>dbase_pack</function>.
   </simpara>
   <simpara>
    We recommend that you do not use dBase files as your production
    database. Choose any real SQL server instead; MySQL or Postgres
    are common choices with PHP. dBase support is here to allow you to
    import and export data to and from your web database, because the
    file format is commonly understood by Windows spreadsheets and
    organizers.
   </simpara>
  </partintro>

  <refentry id="function.dbase-create">
   <refnamediv>
    <refname>dbase_create</refname>
    <refpurpose>Creates a dBase database</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>dbase_create</methodname>
      <methodparam><type>string</type><parameter>filename</parameter></methodparam>
      <methodparam><type>array</type><parameter>fields</parameter></methodparam>
     </methodsynopsis>
    <para>
     The <parameter>fields</parameter> parameter is an array of
     arrays, each array describing the format of one field in the
     database. Each field consists of a name, a character indicating
     the field type, a length, and a precision.
    </para>
    <para>
     The types of fields available are:
     <variablelist>
      <varlistentry>
       <term>L</term>
       <listitem>
        <simpara>
         Boolean. These do not have a length or precision.
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term>M</term>
       <listitem>
        <simpara>
         Memo. (Note that these aren't supported by PHP.)  These do
         not have a length or precision.
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term>D</term>
       <listitem>
        <simpara>
         Date (stored as YYYYMMDD).  These do not have a length or
         precision.
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term>N</term>
       <listitem>
        <simpara>
         Number. These have both a length and a precision (the number
         of digits after the decimal point).
        </simpara>
       </listitem>
      </varlistentry>
      <varlistentry>
       <term>C</term>
       <listitem>
        <simpara>
         String.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </para>
    <para>
     If the database is successfully created, a dbase_identifier is
     returned, otherwise &false; is returned.
     <example>
      <title>Creating a dBase database file</title>
      <programlisting role="php">
<![CDATA[
// "database" name
$dbname = "/tmp/test.dbf";

// database "definition"
$def =
    array(
        array("date",     "D"),
        array("name",     "C",  50),
        array("age",      "N",   3, 0),
        array("email",    "C", 128),
        array("ismember", "L")
    );

// creation
if (!dbase_create($dbname, $def))
    print "<strong>Error!</strong>";
]]>
      </programlisting>
     </example>
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.dbase-open">
   <refnamediv>
    <refname>dbase_open</refname>
    <refpurpose>Opens a dBase database</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>dbase_open</methodname>
      <methodparam><type>string</type><parameter>filename</parameter></methodparam>
      <methodparam><type>int</type><parameter>flags</parameter></methodparam>
     </methodsynopsis>
    <para>
     The flags correspond to those for the open() system call.
     (Typically 0 means read-only, 1 means write-only, and 2 means
     read and write.)
    </para>
    <para>
     Returns a dbase_identifier for the opened database, or &false; if
     the database couldn't be opened.
    </para>
    &note.sm.uidcheck;
   </refsect1>
  </refentry>

  <refentry id="function.dbase-close">
   <refnamediv>
    <refname>dbase_close</refname>
    <refpurpose>Close a dBase database</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>bool</type><methodname>dbase_close</methodname>
      <methodparam><type>int</type><parameter>dbase_identifier</parameter></methodparam>
     </methodsynopsis>
    <para>
     Closes the database associated with
     <parameter>dbase_identifier</parameter>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.dbase-pack">
   <refnamediv>
    <refname>dbase_pack</refname>
    <refpurpose>Packs a dBase database</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>bool</type><methodname>dbase_pack</methodname>
      <methodparam><type>int</type><parameter>dbase_identifier</parameter></methodparam>
     </methodsynopsis>
    <para>
     Packs the specified database (permanently deleting all records
     marked for deletion using
     <function>dbase_delete_record</function>).
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.dbase-add-record">
   <refnamediv>
    <refname>dbase_add_record</refname>
    <refpurpose>Add a record to a dBase database</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>bool</type><methodname>dbase_add_record</methodname>
      <methodparam><type>int</type><parameter>dbase_identifier</parameter></methodparam>
      <methodparam><type>array</type><parameter>record</parameter></methodparam>
     </methodsynopsis>
    <para>
     Adds the data in the <parameter>record</parameter> to the
     database. If the number of items in the supplied record isn't
     equal to the number of fields in the database, the operation will
     fail and &false; will be returned.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.dbase-replace-record">
   <refnamediv>
    <refname>dbase_replace_record</refname>
    <refpurpose>Replace a record in a dBase database</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>bool</type><methodname>dbase_replace_record</methodname>
      <methodparam><type>int</type><parameter>dbase_identifier</parameter></methodparam>
      <methodparam><type>array</type><parameter>record</parameter></methodparam>
      <methodparam><type>int</type><parameter>dbase_record_number</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     Replaces the data associated with the record
     <parameter>record_number</parameter> with the data in the
     <parameter>record</parameter> in the database. If the number of
     items in the supplied record is not equal to the number of fields
     in the database, the operation will fail and &false; will be
     returned.
    </simpara>
    <simpara>
     <parameter>dbase_record_number</parameter> is an integer which
     spans from 1 to the number of records in the database (as
     returned by <function>dbase_numrecords</function>).
    </simpara>
   </refsect1>
  </refentry>

  <refentry id="function.dbase-delete-record">
   <refnamediv>
    <refname>dbase_delete_record</refname>
    <refpurpose>Deletes a record from a dBase database</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>bool</type><methodname>dbase_delete_record</methodname>
      <methodparam><type>int</type><parameter>dbase_identifier</parameter></methodparam>
      <methodparam><type>int</type><parameter>record</parameter></methodparam>
     </methodsynopsis>
    <para>
     Marks <parameter>record</parameter> to be deleted from the
     database.  To actually remove the record from the database, you
     must also call <function>dbase_pack</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.dbase-get-record">
   <refnamediv>
    <refname>dbase_get_record</refname>
    <refpurpose>Gets a record from a dBase database</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>array</type><methodname>dbase_get_record</methodname>
      <methodparam><type>int</type><parameter>dbase_identifier</parameter></methodparam>
      <methodparam><type>int</type><parameter>record</parameter></methodparam>
     </methodsynopsis>
    <para>
     Returns the data from <parameter>record</parameter> in an
     array. The array is indexed starting at 0, and includes an
     associative member named 'deleted' which is set to 1 if the
     record has been marked for deletion (see
     <function>dbase_delete_record</function>.
    </para>
    <para>
     Each field is converted to the appropriate PHP type, except:
     <itemizedlist>
      <listitem>
       <simpara>
        Dates are left as strings
       </simpara>
      </listitem>
      <listitem>
       <simpara>
        Integers that would have caused an overflow (> 32 bits)
        are returned as strings
       </simpara>
      </listitem>
     </itemizedlist>
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.dbase-get-record-with-names">
   <refnamediv>
    <refname>dbase_get_record_with_names</refname>
    <refpurpose>
     Gets a record from a dBase database as an associative array
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>array</type><methodname>dbase_get_record_with_names</methodname>
      <methodparam><type>int</type><parameter>dbase_identifier</parameter></methodparam>
      <methodparam><type>int</type><parameter>record</parameter></methodparam>
     </methodsynopsis>
    <para>
     Returns the data from <parameter>record</parameter> in an
     associative array.  The array also includes an associative member
     named 'deleted' which is set to 1 if the record has been marked
     for deletion (see <function>dbase_delete_record</function>).
    </para>
    <para>
     Each field is converted to the appropriate PHP type, except:
     <itemizedlist>
      <listitem>
       <simpara>
        Dates are left as strings
       </simpara>
      </listitem>
      <listitem>
       <simpara>
        Integers that would have caused an overflow (> 32 bits)
        are returned as strings
       </simpara>
      </listitem>
     </itemizedlist>
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.dbase-numfields">
   <refnamediv>
    <refname>dbase_numfields</refname>
    <refpurpose>
     Find out how many fields are in a dBase database
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>dbase_numfields</methodname>
      <methodparam><type>int</type><parameter>dbase_identifier</parameter></methodparam>
     </methodsynopsis>
    <para>
     Returns the number of fields (columns) in the specified
     database. Field numbers are between 0 and dbase_numfields($db)-1,
     while record numbers are between 1 and dbase_numrecords($db).
     <example>
      <title>Using <function>dbase_numfields</function></title>
      <programlisting role="php">
<![CDATA[
$rec = dbase_get_record($db, $recno);
$nf  = dbase_numfields($db);
for ($i=0; $i < $nf; $i++) {
    print $rec[$i]."<br>\n";
}
]]>
      </programlisting>
     </example>
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.dbase-numrecords">
   <refnamediv>
    <refname>dbase_numrecords</refname>
    <refpurpose>
     Find out how many records are in a dBase database
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>dbase_numrecords</methodname>
      <methodparam><type>int</type><parameter>dbase_identifier</parameter></methodparam>
     </methodsynopsis>
    <para>
     Returns the number of records (rows) in the specified
     database. Record numbers are between 1 and dbase_numrecords($db),
     while field numbers are between 0 and dbase_numfields($db)-1.
    </para>
   </refsect1>
  </refentry>

 </reference>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->