cvs: phpdoc /en language-snippets.ent /en/reference/dbase reference.xml /en/reference/dbase/functions dbase-add-record.xml dbase-close.xml
dbase-create.xml dbase-delete-record.xml dbase-get-header-info.xml dbase-get-record-with-names.xml dbase-get-record.xml dbase-numfields.xml
dbase-numrecords.xml dbase-open.xml dbase-pack.xml dbase-replace-record.xml

From: Date: Sat, 29 Jan 2005 23:23:50 +0000
Subject: cvs: phpdoc /en language-snippets.ent /en/reference/dbase reference.xml /en/reference/dbase/functions dbase-add-record.xml dbase-close.xml
dbase-create.xml dbase-delete-record.xml dbase-get-header-info.xml dbase-get-record-with-names.xml dbase-get-record.xml dbase-numfields.xml
dbase-numrecords.xml dbase-open.xml dbase-pack.xml dbase-replace-record.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969366251@lists.php.net to get a copy of this message
didou Sat Jan 29 18:23:50 2005 EDT Modified files: /phpdoc/en language-snippets.ent /phpdoc/en/reference/dbase reference.xml /phpdoc/en/reference/dbase/functions dbase-add-record.xml dbase-close.xml dbase-create.xml dbase-delete-record.xml dbase-get-header-info.xml dbase-get-record-with-names.xml dbase-get-record.xml dbase-numfields.xml dbase-numrecords.xml dbase-open.xml dbase-pack.xml dbase-replace-record.xml Log: Move the fields documentation to reference.xml and add more information dbase_create and dbase_open are affected by safemode and open_basedir dbase_open doesn't work with mode = 1 (bug #31754) add examples with a generic dBase file Clean the refpurposes

http://cvs.php.net/diff.php/phpdoc/en/language-snippets.ent?r1=1.132&r2=1.133&ty=u Index: phpdoc/en/language-snippets.ent diff -u phpdoc/en/language-snippets.ent:1.132 phpdoc/en/language-snippets.ent:1.133 --- phpdoc/en/language-snippets.ent:1.132 Fri Jan 14 00:49:21 2005 +++ phpdoc/en/language-snippets.ent Sat Jan 29 18:23:50 2005 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.132 $ --> +<!-- $Revision: 1.133 $ --> <!-- Keep 'em sorted --> @@ -238,6 +238,10 @@ the directory in which you are about to operate has the same UID (owner) as the script that is being executed.</simpara></note>'> +<!ENTITY note.open-basedir.func '<note><para>This function is affected by <link +linkend="ini.open-basedir">open_basedir</link>,</para></note>'> + + <!ENTITY note.language-construct '<note><simpara>Because this is a language construct and not a function, it cannot be called using <link linkend="functions.variable-functions">variable functions</link></simpara> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/reference.xml?r1=1.5&r2=1.6&ty=u Index: phpdoc/en/reference/dbase/reference.xml diff -u phpdoc/en/reference/dbase/reference.xml:1.5 phpdoc/en/reference/dbase/reference.xml:1.6 --- phpdoc/en/reference/dbase/reference.xml:1.5 Tue Feb 24 03:45:30 2004 +++ phpdoc/en/reference/dbase/reference.xml Sat Jan 29 18:23:50 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <reference id="ref.dbase"> <title>dBase Functions</title> <titleabbrev>dBase</titleabbrev> @@ -12,24 +12,79 @@ (dbf) databases. </para> <para> - 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. + 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>. </para> <para> - 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>. - </para> - <para> - 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. + The types of dBase fields available are: + <table> + <title>Available types of fields</title> + <tgroup cols="3"> + <thead> + <row> + <entry>Field</entry> + <entry>dBase Type</entry> + <entry>Format</entry> + <entry>Additional informations</entry> + </row> + </thead> + <tbody> + <row> + <entry><literal>M</literal></entry> + <entry>Memo</entry> + <entry>n/a</entry> + <entry>This type is not supported by PHP, such field will be ignored</entry> + </row> + <row> + <entry><literal>D</literal></entry> + <entry>Date</entry> + <entry><literal>YYYYMMDD</literal></entry> + <entry>The field length is limited to 8</entry> + </row> + <row> + <entry><literal>N</literal></entry> + <entry>Number</entry> + <entry>A number</entry> + <entry> + You must declare a length and a precision (the number of digits + after the decimal point) + </entry> + </row> + <row> + <entry><literal>C</literal></entry> + <entry>String</entry> + <entry>A string</entry> + <entry>You must declare a length. When retrieving data, the string + will be right-padded with spaces to fit the declared length.</entry> + </row> + <row> + <entry><literal>L</literal></entry> + <entry>Boolean</entry> + <entry><literal>T</literal> or <literal>Y</literal> for &true;, + <literal>F</literal> or <literal>N</literal> for &false;</entry> + <entry>Stored and returned as an integer (1 ot 0)</entry> + </row> + </tbody> + </tgroup> + </table> </para> + <warning> + <para> + 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. + </para> + <para> + We recommend that you do not use dBase files as your production + database. Choose any real SQL server instead; <ulink + url="&url.mysql;">MySQL</ulink> or <ulink url="&url.pgsql;">Postgres</ulink> + 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. + </para> + </warning> </section> &reference.dbase.configure; @@ -44,6 +99,15 @@ &no.resource; </section> + <section id="dbase.examples"> + &reftitle.examples; + <para> + Many examples in this reference require a dBase database. We will use + <filename>/tmp/test.dbf</filename> that will be created in the example of + <function>dbase_create</function>. + </para> + </section> + <section id="dbase.constants"> &reftitle.constants; &no.constants; http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-add-record.xml?r1=1.3&r2=1.4&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-add-record.xml diff -u phpdoc/en/reference/dbase/functions/dbase-add-record.xml:1.3 phpdoc/en/reference/dbase/functions/dbase-add-record.xml:1.4 --- phpdoc/en/reference/dbase/functions/dbase-add-record.xml:1.3 Sat Jan 29 12:18:51 2005 +++ phpdoc/en/reference/dbase/functions/dbase-add-record.xml Sat Jan 29 18:23:50 2005 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="function.dbase-add-record"> <refnamediv> <refname>dbase_add_record</refname> - <refpurpose>Add a record to a dBase database</refpurpose> + <refpurpose>Adds a record to a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -24,7 +24,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> @@ -54,6 +54,34 @@ &return.success; </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Inserting a record in a dBase database</title> + <programlisting role="php"> +<![CDATA[ +<?php + +// open in read-write mode +$db = dbase_open('/tmp/test.dbf', 2); + +if ($db) { + dbase_add_record($db, array( + date('Ymd'), + 'Maxim Topolov', + '23', + 'max@example.com', + 'T')); + dbase_close($db); +} + +?> +]]> + </programlisting> + </example> + </para> + </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-close.xml?r1=1.3&r2=1.4&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-close.xml diff -u phpdoc/en/reference/dbase/functions/dbase-close.xml:1.3 phpdoc/en/reference/dbase/functions/dbase-close.xml:1.4 --- phpdoc/en/reference/dbase/functions/dbase-close.xml:1.3 Fri Jan 28 12:30:43 2005 +++ phpdoc/en/reference/dbase/functions/dbase-close.xml Sat Jan 29 18:23:50 2005 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="function.dbase-close"> <refnamediv> <refname>dbase_close</refname> - <refpurpose>Close a dBase database</refpurpose> + <refpurpose>Closes a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -23,7 +23,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> @@ -37,6 +37,30 @@ &return.success; </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Closing a dBase database file</title> + <programlisting role="php"> +<![CDATA[ +<?php + +// open in read-only mode +$db = dbase_open('/tmp/test.dbf', 0); + +if ($db) { + // read some data .. + + dbase_close($db); +} + +?> +]]> + </programlisting> + </example> + </para> + </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-create.xml?r1=1.7&r2=1.8&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-create.xml diff -u phpdoc/en/reference/dbase/functions/dbase-create.xml:1.7 phpdoc/en/reference/dbase/functions/dbase-create.xml:1.8 --- phpdoc/en/reference/dbase/functions/dbase-create.xml:1.7 Sat Jan 29 12:18:51 2005 +++ phpdoc/en/reference/dbase/functions/dbase-create.xml Sat Jan 29 18:23:50 2005 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry id="function.dbase-create"> <refnamediv> <refname>dbase_create</refname> - <refpurpose>Creates a dBase database</refpurpose> + <refpurpose>Creates a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -16,6 +16,8 @@ <function>dbase_create</function> creates a dBase database with the given definition. </para> + &note.sm.uidcheck; + &note.open-basedir.func; </refsect1> <refsect1 role="parameters"> &reftitle.parameters; @@ -36,65 +38,13 @@ <para> An array of arrays, each array describing the format of one field of the database. Each field consists of a name, a character indicating the field - type, a length, and a precision. + type, and optionally, a length, and a precision. </para> <note> <para> The fieldnames are limited in length and must not exceed 10 chars, </para> </note> - <para> - The types of fields available are: - <variablelist> - <varlistentry> - <term>L</term> - <listitem> - <para> - Boolean. These do not have a length or precision. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term>M</term> - <listitem> - <para> - Memo. These do not have a length or precision. - </para> - <note> - <para> - This type is not supported by PHP. - </para> - </note> - </listitem> - </varlistentry> - <varlistentry> - <term>D</term> - <listitem> - <para> - Date (stored as <literal>YYYYMMDD</literal>). These do not have a - length or precision. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term>N</term> - <listitem> - <para> - Number. These have both a length and a precision (the number - of digits after the decimal point). - </para> - </listitem> - </varlistentry> - <varlistentry> - <term>C</term> - <listitem> - <para> - String. - </para> - </listitem> - </varlistentry> - </variablelist> - </para> </listitem> </varlistentry> </variablelist> @@ -116,21 +66,18 @@ <![CDATA[ <?php -// "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") + 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)) { - echo "Error, can't create $dbname"; +if (!dbase_create('/tmp/test.dbf', $def)) { + echo "Error, can't create the database\n"; } ?> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-delete-record.xml?r1=1.3&r2=1.4&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-delete-record.xml diff -u phpdoc/en/reference/dbase/functions/dbase-delete-record.xml:1.3 phpdoc/en/reference/dbase/functions/dbase-delete-record.xml:1.4 --- phpdoc/en/reference/dbase/functions/dbase-delete-record.xml:1.3 Sat Jan 29 12:18:51 2005 +++ phpdoc/en/reference/dbase/functions/dbase-delete-record.xml Sat Jan 29 18:23:50 2005 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="function.dbase-delete-record"> <refnamediv> <refname>dbase_delete_record</refname> - <refpurpose>Deletes a record from a dBase database</refpurpose> + <refpurpose>Deletes a record from a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -30,7 +30,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-get-header-info.xml?r1=1.4&r2=1.5&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-get-header-info.xml diff -u phpdoc/en/reference/dbase/functions/dbase-get-header-info.xml:1.4 phpdoc/en/reference/dbase/functions/dbase-get-header-info.xml:1.5 --- phpdoc/en/reference/dbase/functions/dbase-get-header-info.xml:1.4 Fri Jan 28 12:30:43 2005 +++ phpdoc/en/reference/dbase/functions/dbase-get-header-info.xml Sat Jan 29 18:23:50 2005 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <refentry id="function.dbase-get-header-info"> <refnamediv> <refname>dbase_get_header_info</refname> - <refpurpose>Get the header info of a dBase database</refpurpose> + <refpurpose>Gets the header info of a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -24,7 +24,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> @@ -109,7 +109,7 @@ $db_path = "/tmp/test.dbf"; // Open dbase file -$dbh = dbase_open($db_path) +$dbh = dbase_open($db_path, 0) or die("Error! Could not open dbase database file '$db_path'."); // Get column information http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-get-record-with-names.xml?r1=1.4&r2=1.5&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-get-record-with-names.xml diff -u phpdoc/en/reference/dbase/functions/dbase-get-record-with-names.xml:1.4 phpdoc/en/reference/dbase/functions/dbase-get-record-with-names.xml:1.5 --- phpdoc/en/reference/dbase/functions/dbase-get-record-with-names.xml:1.4 Sat Jan 29 12:18:51 2005 +++ phpdoc/en/reference/dbase/functions/dbase-get-record-with-names.xml Sat Jan 29 18:23:50 2005 @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <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 + Gets a record from a database as an associative array </refpurpose> </refnamediv> <refsect1 role="description"> @@ -26,7 +26,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> @@ -69,6 +69,32 @@ On error, <function>dbase_get_record_with_names</function> will return &false; </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Listing all the registred members in the database</title> + <programlisting role="php"> +<![CDATA[ +<?php +// open in read-only mode +$db = dbase_open('/tmp/test.dbf', 0); + +if ($db) { + $record_numbers = dbase_numrecords($db); + for ($i = 1; $i <= $record_numbers; $i++) { + $row = dbase_get_record_with_names($db, $i); + if ($row['ismember'] == 1) { + echo "Member #$i: " . trim($row['name']) . "\n"; + } + } +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-get-record.xml?r1=1.4&r2=1.5&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-get-record.xml diff -u phpdoc/en/reference/dbase/functions/dbase-get-record.xml:1.4 phpdoc/en/reference/dbase/functions/dbase-get-record.xml:1.5 --- phpdoc/en/reference/dbase/functions/dbase-get-record.xml:1.4 Sat Jan 29 12:18:51 2005 +++ phpdoc/en/reference/dbase/functions/dbase-get-record.xml Sat Jan 29 18:23:50 2005 @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <refentry id="function.dbase-get-record"> <refnamediv> <refname>dbase_get_record</refname> <refpurpose> - Gets a record from a dBase database as an indexed array + Gets a record from a database as an indexed array </refpurpose> </refnamediv> <refsect1 role="description"> @@ -15,7 +15,7 @@ <methodparam><type>int</type><parameter>record_number</parameter></methodparam> </methodsynopsis> <para> - Gets a record from a dBase database as an indexed array. + Gets a record from athe database as an indexed array. </para> </refsect1> <refsect1 role="parameters"> @@ -26,7 +26,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-numfields.xml?r1=1.5&r2=1.6&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-numfields.xml diff -u phpdoc/en/reference/dbase/functions/dbase-numfields.xml:1.5 phpdoc/en/reference/dbase/functions/dbase-numfields.xml:1.6 --- phpdoc/en/reference/dbase/functions/dbase-numfields.xml:1.5 Sat Jan 29 12:18:51 2005 +++ phpdoc/en/reference/dbase/functions/dbase-numfields.xml Sat Jan 29 18:23:50 2005 @@ -1,11 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry id="function.dbase-numfields"> <refnamediv> <refname>dbase_numfields</refname> - <refpurpose> - Find out how many fields are in a dBase database - </refpurpose> + <refpurpose>Gets the number of fields of a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -31,7 +29,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-numrecords.xml?r1=1.3&r2=1.4&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-numrecords.xml diff -u phpdoc/en/reference/dbase/functions/dbase-numrecords.xml:1.3 phpdoc/en/reference/dbase/functions/dbase-numrecords.xml:1.4 --- phpdoc/en/reference/dbase/functions/dbase-numrecords.xml:1.3 Sat Jan 29 12:18:51 2005 +++ phpdoc/en/reference/dbase/functions/dbase-numrecords.xml Sat Jan 29 18:23:50 2005 @@ -1,11 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="function.dbase-numrecords"> <refnamediv> <refname>dbase_numrecords</refname> - <refpurpose> - Find out how many records are in a dBase database - </refpurpose> + <refpurpose>Gets the number of records in a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -31,7 +29,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> @@ -45,6 +43,31 @@ The number of records in the database, or &false; if an error occurs. </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Looping over all the records of the database</title> + <programlisting role="php"> +<![CDATA[ +<?php + +// open in read-only mode +$db = dbase_open('/tmp/test.dbf', 0); + +if ($db) { + $record_numbers = dbase_numrecords($db); + for ($i = 1; $i <= $record_numbers; $i++) { + // do something here, for each record + } +} + +?> +]]> + </programlisting> + </example> + </para> + </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-open.xml?r1=1.5&r2=1.6&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-open.xml diff -u phpdoc/en/reference/dbase/functions/dbase-open.xml:1.5 phpdoc/en/reference/dbase/functions/dbase-open.xml:1.6 --- phpdoc/en/reference/dbase/functions/dbase-open.xml:1.5 Sat Jan 29 12:18:51 2005 +++ phpdoc/en/reference/dbase/functions/dbase-open.xml Sat Jan 29 18:23:50 2005 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry id="function.dbase-open"> <refnamediv> <refname>dbase_open</refname> - <refpurpose>Opens a dBase database</refpurpose> + <refpurpose>Opens a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -12,11 +12,12 @@ <methodparam><type>string</type><parameter>filename</parameter></methodparam> <methodparam><type>int</type><parameter>mode</parameter></methodparam> </methodsynopsis> - <para> + <para> <function>dbase_open</function> opens a dBase database with the given access mode. </para> &note.sm.uidcheck; + &note.open-basedir.func; </refsect1> <refsect1 role="parameters"> &reftitle.parameters; @@ -39,11 +40,41 @@ system call (Typically 0 means read-only, 1 means write-only, and 2 means read and write). </para> + <note> + <para> + Actually, you can't open a dBase file in write-only mode as the function + will fail to read the headers infomation. + </para> + </note> </listitem> </varlistentry> </variablelist> </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Opening a dBase database file</title> + <programlisting role="php"> +<![CDATA[ +<?php + +// open in read-only mode +$db = dbase_open('/tmp/test.dbf', 0); + +if ($db) { + // read some data .. + + dbase_close($db); +} + +?> +]]> + </programlisting> + </example> + </para> + </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-pack.xml?r1=1.3&r2=1.4&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-pack.xml diff -u phpdoc/en/reference/dbase/functions/dbase-pack.xml:1.3 phpdoc/en/reference/dbase/functions/dbase-pack.xml:1.4 --- phpdoc/en/reference/dbase/functions/dbase-pack.xml:1.3 Sat Jan 29 12:18:51 2005 +++ phpdoc/en/reference/dbase/functions/dbase-pack.xml Sat Jan 29 18:23:50 2005 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="function.dbase-pack"> <refnamediv> <refname>dbase_pack</refname> - <refpurpose>Packs a dBase database</refpurpose> + <refpurpose>Packs a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -24,7 +24,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> @@ -38,6 +38,33 @@ &return.success; </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Emptying a dBase database</title> + <programlisting role="php"> +<![CDATA[ +<?php + +// open in read-write mode +$db = dbase_open('/tmp/test.dbf', 2); + +if ($db) { + $record_numbers = dbase_numrecords($db); + for ($i = 1; $i <= $record_numbers; $i++) { + dbase_delete_record($db, $i); + } + // expunge the database + dbase_pack($db); +} + +?> +]]> + </programlisting> + </example> + </para> + </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/diff.php/phpdoc/en/reference/dbase/functions/dbase-replace-record.xml?r1=1.4&r2=1.5&ty=u Index: phpdoc/en/reference/dbase/functions/dbase-replace-record.xml diff -u phpdoc/en/reference/dbase/functions/dbase-replace-record.xml:1.4 phpdoc/en/reference/dbase/functions/dbase-replace-record.xml:1.5 --- phpdoc/en/reference/dbase/functions/dbase-replace-record.xml:1.4 Sat Jan 29 12:19:52 2005 +++ phpdoc/en/reference/dbase/functions/dbase-replace-record.xml Sat Jan 29 18:23:50 2005 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <refentry id="function.dbase-replace-record"> <refnamediv> <refname>dbase_replace_record</refname> - <refpurpose>Replace a record in a dBase database</refpurpose> + <refpurpose>Replaces a record in a database</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -25,7 +25,7 @@ <term><parameter>dbase_identifier</parameter></term> <listitem> <para> - The dbase link identifier, returned by <function>dbase_open</function> + The database link identifier, returned by <function>dbase_open</function> or <function>dbase_create</function>. </para> </listitem> @@ -64,6 +64,39 @@ &return.success; </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Updating a record in the database</title> + <programlisting role="php"> +<![CDATA[ +<?php + +// open in read-write mode +$db = dbase_open('/tmp/test.dbf', 2); + +if ($db) { + // gets the old row + $row = dbase_get_record_with_names($db, 1); + + // remove the 'deleted' entry + unset($row['deleted']); + + // Update the date field with the current timestamp + $row['date'] = date('Ymd'); + + // Replace the record + dbase_replace_record($db, $row, 1); + dbase_close($db); +} + +?> +]]> + </programlisting> + </example> + </para> + </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para>
« previous php.doc (#969366251) next »