PECL repository and is no longer bundled with PHP as of PHP 5.3.0. Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions.) // ============================== USING FUNCTIONS (12) // dbase_add_record() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_close() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_create() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_delete_record() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_get_header_info() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_get_record_with_names() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_get_record() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_numfields() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_numrecords() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_open() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_pack() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // dbase_replace_record() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== USING CLASSES (0) // ============================== USING DATA_TYPES (6) // bool // resource // array // string // int // false // ============================== END // REQUIREMENTS // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE // ============================== ABOUT // PHP Manual / Function Reference / Database Extensions / Vendor Specific Database Extensions / dBase // URL: https://www.php.net/manual/en/book.dbase.php // ============================== DESCRIPTION // DBASE // // DBASE - BEGIN // dBase // // INTRODUCTION // INSTALLING_CONFIGURING // PREDEFINED_CONSTANTS // DBASE_FUNCTIONS // // INTRODUCTION - BEGIN // Introduction // // Note: This extension has been moved to the > PECL repository and is no longer bundled with PHP as of PHP 5.3.0. // These functions allow you to access records stored in dBase-format (dbf) databases. // Warning: We recommend against using dBase files as your production database. Use > SQLite or 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. // Caution: As of dbase 7.0.0 the databases are automatically locked via flock(). There has been no support for locking earlier, so two concurrent web server processes modifying the same dBase file would have very likely ruined your database. This can happen even with dbase 7.0.0+ on systems which implement the locks at the process level with multithreaded SAPIs. // dBase files are simple sequential files of fixed length records. Records are appended to the end of the file and deleted records are kept until you call dbase_pack(). // Only dbf file levels 3 (dBASE III+) - 5 (dBASE V) are supported. The types of dBase fields available are: // // Available types of fields // Field | dBase Type | Format | Additional information // M | Memo | n/a | This type is not supported by PHP, such field will be ignored // D | Date | YYYYMMDD | The field length is limited to 8 // T | DateTime | YYYYMMDDhhmmss.uuu | (FoxPro) No validity checks are done. Available as of dbase 7.0.0. // N | Number | A number | You must declare a length and a precision (the number of digits after the decimal point). // F | Float | A float number | Same as N. // C | String | A string | You must declare a length. When retrieving data, the string will be right-padded with spaces to fit the declared length. Overlong strings will be silently truncated when storing data. // L | Boolean | T or Y for true, F or N for false, ? for uninitialized. | As of dbase 7.0.0, returned as a bool (true or false), or null for uninitialized fields. Formerly, returned as an int (1 or 0). // // Note: As of dbase 7.0.0 nullable fields are supported for DBASE_TYPE_FOXPRO databases. If a field is nullable, passing null will set the respective flag, and on later retrieval the field value will be null. // Note: There is no support for indexes or memo fields. // // LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/intro.dbase.php // INTRODUCTION - END // // INSTALLING_CONFIGURING - BEGIN // Installing/Configuring // // REQUIREMENTS // INSTALLATION // RUNTIME_CONFIGURATION // RESOURCE_TYPES // // REQUIREMENTS - BEGIN // Requirements // // No external libraries are needed to build this extension. // // LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/dbase.requirements.php // REQUIREMENTS - END // // INSTALLATION - BEGIN // Installation // // Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: > https://pecl.php.net/package/dbase. // // LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/dbase.installation.php // INSTALLATION - END // // RUNTIME_CONFIGURATION - BEGIN // Runtime Configuration // // This extension has no configuration directives defined in php.ini. // // LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/dbase.configuration.php // RUNTIME_CONFIGURATION - END // // RESOURCE_TYPES - BEGIN // Resource Types // // As of dbase 7.0.0, the resource type dbase is defined, which is returned by dbase_open() and dbase_create(). // // LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/dbase.resources.php // RESOURCE_TYPES - END // // LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/dbase.setup.php // INSTALLING_CONFIGURING - END // // PREDEFINED_CONSTANTS - BEGIN // Predefined Constants // // The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. // // DBASE_VERSION (string) - The extension version. (Available as of dbase 7.0.0) // DBASE_RDONLY (int) - Open database for reading only. Used with dbase_open(). (Available as of dbase 7.0.0) // DBASE_RDWR (int) - Open database for reading and writing. Used with dbase_open(). (Available as of dbase 7.0.0) // DBASE_TYPE_DBASE (int) - Create dBASE style database. Used with dbase_create(). (Available as of dbase 7.0.0) // DBASE_TYPE_FOXPRO (int) - Create FoxPro style database. Used with dbase_create(). (Available as of dbase 7.0.0) // // LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/dbase.constants.php // PREDEFINED_CONSTANTS - END // // DBASE_FUNCTIONS - BEGIN // dBase Functions // // [examples] // Examples // Many examples in this reference require a dBase database. We will use /tmp/test.dbf that will be created in the example of dbase_create(). // [/examples] // // Table of Contents // * dbase_add_record - Adds a record to a database // * dbase_close - Closes a database // * dbase_create - Creates a database // * dbase_delete_record - Deletes a record from a database // * dbase_get_header_info - Gets the header info of a database // * dbase_get_record_with_names - Gets a record from a database as an associative array // * dbase_get_record - Gets a record from a database as an indexed array // * dbase_numfields - Gets the number of fields of a database // * dbase_numrecords - Gets the number of records in a database // * dbase_open - Opens a database // * dbase_pack - Packs a database // * dbase_replace_record - Replaces a record in a database // // LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/ref.dbase.php // DBASE_FUNCTIONS - END // // LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/book.dbase.php // DBASE - END // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_ADD_RECORD // ============================== PUBLIC // ============================== ABOUT // Adds a record to a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_add_record() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_add_record($database, $data) { $return_dbase_add_record = false; // ========== DBASE_ADD_RECORD - BEGIN // ===== ABOUT // Adds a record to a database // ===== DESCRIPTION // Adds the given data to the database. // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_add_record(resource $database, array $data): bool // ===== CODE $return_dbase_add_record = dbase_add_record( $database, // resource database - The database resource, returned by dbase_open() or dbase_create(). $data // array data - An indexed array of data. The number of items must be equal to the number of fields in the database, otherwise dbase_add_record() will fail. // Note: If you're using dbase_get_record() return value for this parameter, remember to reset the key named deleted. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 Inserting a record in a dBase database // [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); // } // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-add-record.php // ========== DBASE_ADD_RECORD - END // SYNTAX: // bool dbase_add_record(resource $database, array $data) return $return_dbase_add_record; // bool } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_ADD_RECORD // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_CLOSE // ============================== PUBLIC // ============================== ABOUT // Closes a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_close() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_close($database) { $return_dbase_close = false; // ========== DBASE_CLOSE - BEGIN // ===== ABOUT // Closes a database // ===== DESCRIPTION // Closes the given database resource. // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_close(resource $database): bool // ===== CODE $return_dbase_close = dbase_close( $database // resource database - The database resource, returned by dbase_open() or dbase_create(). ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 Closing a dBase database file // [php] // // // open in read-only mode // $db = dbase_open('/tmp/test.dbf', 0); // // if ($db) { // // read some data .. // // dbase_close($db); // } // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-close.php // ========== DBASE_CLOSE - END // SYNTAX: // bool dbase_close(resource $database) return $return_dbase_close; // bool } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_CLOSE // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_CREATE // ============================== PUBLIC // ============================== ABOUT // Creates a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_create() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== USING CONSTANTS (1) // DBASE_TYPE_DBASE - dbase_create() // ============================== CODE function php_database_vendor_dbase_dbase_create($path, $fields, $type = DBASE_TYPE_DBASE) { $return_dbase_create = null; // ========== DBASE_CREATE - BEGIN // ===== ABOUT // Creates a database // ===== DESCRIPTION // dbase_create() creates a dBase database with the given definition. If the file already exists, it is not truncated. dbase_pack() can be called to force truncation. // Note: This function is affected by open_basedir. // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_create(string $path, array $fields, int $type = DBASE_TYPE_DBASE): resource // ===== CODE $return_dbase_create = dbase_create( $path, // string path - The path of the database. It can be a relative or absolute path to the file where dBase will store your data. $fields, // array fields - 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, and optionally, a length, a precision and a nullable flag. The supported field types are listed in the introduction section. // Note: The fieldnames are limited in length and must not exceed 10 chars. $type // int type - The type of database to be created. Either DBASE_TYPE_DBASE or DBASE_TYPE_FOXPRO. ); // Return Values // Returns a database resource if the database is successfully created, or false if an error occurred. // // Changelog // Version - Description // dbase 7.0.0 - The type parameter has been added. // dbase 7.0.0 - The return value is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 Creating a dBase database file // [php] // // // 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('/tmp/test.dbf', $def)) { // echo "Error, can't create the database\n"; // } // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-create.php // ========== DBASE_CREATE - END // SYNTAX: // resource dbase_create(string $path, array $fields, int $type = DBASE_TYPE_DBASE) return $return_dbase_create; // resource } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_CREATE // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_DELETE_RECORD // ============================== PUBLIC // ============================== ABOUT // Deletes a record from a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_delete_record() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_delete_record($database, $number) { $return_dbase_delete_record = false; // ========== DBASE_DELETE_RECORD - BEGIN // ===== ABOUT // Deletes a record from a database // ===== DESCRIPTION // Marks the given record to be deleted from the database. // Note: To actually remove the record from the database, you must also call dbase_pack(). // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_delete_record(resource $database, int $number): bool // ===== CODE $return_dbase_delete_record = dbase_delete_record( $database, // resource database - The database resource, returned by dbase_open() or dbase_create(). $number // int number - An integer which spans from 1 to the number of records in the database (as returned by dbase_numrecords()). ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-delete-record.php // ========== DBASE_DELETE_RECORD - END // SYNTAX: // bool dbase_delete_record(resource $database, int $number) return $return_dbase_delete_record; // bool } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_DELETE_RECORD // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_GET_HEADER_INFO // ============================== PUBLIC // ============================== ABOUT // Gets the header info of a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_get_header_info() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_get_header_info($database) { $return_dbase_get_header_info = null; // ========== DBASE_GET_HEADER_INFO - BEGIN // ===== ABOUT // Gets the header info of a database // ===== DESCRIPTION // Returns information on the column structure of the given database resource. // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_get_header_info(resource $database): array // ===== CODE $return_dbase_get_header_info = dbase_get_header_info( $database // resource database - The database resource, returned by dbase_open() or dbase_create(). ); // Return Values // An indexed array with an entry for each column in the database. The array index starts at 0. // Each array element contains an associative array of column information, as described here: // name - The name of the column // type - The human-readable name for the dbase type of the column (i.e. date, boolean, etc.) The supported field types are listed in the introduction section. // length - The number of bytes this column can hold // precision - The number of digits of decimal precision for the column // format - A suggested printf() format specifier for the column // offset - The byte offset of the column from the start of the row // If the database header information cannot be read, false is returned. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 Showing header information for a dBase database file // [php] // // Path to dbase file // $db_path = "/tmp/test.dbf"; // // // Open dbase file // $dbh = dbase_open($db_path, 0) // or die("Error! Could not open dbase database file '$db_path'."); // // // Get column information // $column_info = dbase_get_header_info($dbh); // // // Display information // print_r($column_info); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-get-header-info.php // ========== DBASE_GET_HEADER_INFO - END // SYNTAX: // array dbase_get_header_info(resource $database) return $return_dbase_get_header_info; // array } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_GET_HEADER_INFO // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_GET_RECORD_WITH_NAMES // ============================== PUBLIC // ============================== ABOUT // Gets a record from a database as an associative array. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_get_record_with_names() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_get_record_with_names($database, $number) { $return_dbase_get_record_with_names = null; // ========== DBASE_GET_RECORD_WITH_NAMES - BEGIN // ===== ABOUT // Gets a record from a database as an associative array // ===== DESCRIPTION // Gets a record from a dBase database as an associative array. // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_get_record_with_names(resource $database, int $number): array // ===== CODE $return_dbase_get_record_with_names = dbase_get_record_with_names( $database, // resource database - The database resource, returned by dbase_open() or dbase_create(). $number // int number - The index of the record between 1 and dbase_numrecords($dbase_identifier). ); // Return Values // An associative array with the record. This will also include a key named deleted which is set to 1 if the record has been marked for deletion (see dbase_delete_record()). Therefore it is not possible to retrieve the value of a field named deleted with this function. // Each field is converted to the appropriate PHP type, except: // * Dates are left as strings. // * DateTime values are converted to strings. // * Integers outside the range PHP_INT_MIN..PHP_INT_MAX are returned as strings. // * Before dbase 7.0.0, booleans (L) were converted to 1 or 0. // On error, dbase_get_record_with_names() will return false. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 Listing all the registered members in the database // [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"; // } // } // } // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-get-record-with-names.php // ========== DBASE_GET_RECORD_WITH_NAMES - END // SYNTAX: // array dbase_get_record_with_names(resource $database, int $number) return $return_dbase_get_record_with_names; // array } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_GET_RECORD_WITH_NAMES // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_GET_RECORD // ============================== PUBLIC // ============================== ABOUT // Gets a record from a database as an indexed array. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_get_record() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_get_record($database, $number) { $return_dbase_get_record = null; // ========== DBASE_GET_RECORD - BEGIN // ===== ABOUT // Gets a record from a database as an indexed array // ===== DESCRIPTION // Gets a record from a database as an indexed array. // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_get_record(resource $database, int $number): array // ===== CODE $return_dbase_get_record = dbase_get_record( $database, // resource database - The database resource, returned by dbase_open() or dbase_create(). $number // int number - The index of the record between 1 and dbase_numrecords($dbase_identifier). ); // Return Values // An indexed array with the record. This array will also include an associative key named deleted which is set to 1 if the record has been marked for deletion (see dbase_delete_record()). // Each field is converted to the appropriate PHP type, except: // * Dates are left as strings. // * DateTime values are converted to strings. // * Integers outside the range PHP_INT_MIN..PHP_INT_MAX are returned as strings. // * Before dbase 7.0.0, booleans (L) were converted to 1 or 0. // On error, dbase_get_record() will return false. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-get-record.php // ========== DBASE_GET_RECORD - END // SYNTAX: // array dbase_get_record(resource $database, int $number) return $return_dbase_get_record; // array } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_GET_RECORD // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_NUMFIELDS // ============================== PUBLIC // ============================== ABOUT // Gets the number of fields of a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_numfields() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_numfields($database) { $return_dbase_numfields = 0; // ========== DBASE_NUMFIELDS - BEGIN // ===== ABOUT // Gets the number of fields of a database // ===== DESCRIPTION // Gets the number of fields (columns) in the specified database. // Note: Field numbers are between 0 and dbase_numfields($db)-1, while record numbers are between 1 and dbase_numrecords($db). // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_numfields(resource $database): int // ===== CODE $return_dbase_numfields = dbase_numfields( $database // resource database - The database resource, returned by dbase_open() or dbase_create(). ); // Return Values // The number of fields in the database, or false if an error occurs. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 dbase_numfields() Example // [php] // // $rec = dbase_get_record($db, $recno); // $nf = dbase_numfields($db); // for ($i = 0; $i < $nf; $i++) { // echo $rec[$i], "\n"; // } // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-numfields.php // ========== DBASE_NUMFIELDS - END // SYNTAX: // int dbase_numfields(resource $database) return $return_dbase_numfields; // int } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_NUMFIELDS // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_NUMRECORDS // ============================== PUBLIC // ============================== ABOUT // Gets the number of records in a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_numrecords() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_numrecords($database) { $return_dbase_numrecords = 0; // ========== DBASE_NUMRECORDS - BEGIN // ===== ABOUT // Gets the number of records in a database // ===== DESCRIPTION // Gets the number of records (rows) in the specified database. // Note: Records which are marked as deleted are counted as well. // Note: Record numbers are between 1 and dbase_numrecords($db), while field numbers are between 0 and dbase_numfields($db)-1. // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_numrecords(resource $database): int // ===== CODE $return_dbase_numrecords = dbase_numrecords( $database // resource database - The database resource, returned by dbase_open() or dbase_create(). ); // Return Values // The number of records in the database, or false if an error occurs. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 Looping over all the records of the database // [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++) { // $record = dbase_get_record($db, $i); // if (!$record['deleted']) { // // do something with the $record // } else { // // do something with the deleted $record or ignore it // } // } // } // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-numrecords.php // ========== DBASE_NUMRECORDS - END // SYNTAX: // int dbase_numrecords(resource $database) return $return_dbase_numrecords; // int } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_NUMRECORDS // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_OPEN // ============================== PUBLIC // ============================== ABOUT // Opens a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_open() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_open($path, $mode) { $return_dbase_open = false; // ========== DBASE_OPEN - BEGIN // ===== ABOUT // Opens a database // ===== DESCRIPTION // dbase_open() opens a dBase database with the given access mode. // Note: This function is affected by open_basedir. // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_open(string $path, int $mode): resource|false // ===== CODE $return_dbase_open = dbase_open( $path, // string path - The path of the database. It can be a relative or absolute path to the file where dBase will store your data. $mode // int mode - An integer which correspond to those for the open() system call (Typically 0 means read-only, 1 means write-only, and 2 means read and write). // Note: You can't open a dBase file in write-only mode as the function will fail to read the headers information and thus you can't use 1 as mode. // As of dbase 7.0.0 you can use DBASE_RDONLY and DBASE_RDWR, respectively, to specify the mode. ); // Return Values // Returns a database resource on success, or false on failure. // // Changelog // Version - Description // dbase 7.0.0 - The return value is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 Opening a dBase database file // [php] // // // open in read-only mode // $db = dbase_open('/tmp/test.dbf', 0); // // if ($db) { // // read some data .. // // dbase_close($db); // } // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-open.php // ========== DBASE_OPEN - END // SYNTAX: // resource|false dbase_open(string $path, int $mode) return $return_dbase_open; // resource|false } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_OPEN // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_PACK // ============================== PUBLIC // ============================== ABOUT // Packs a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_pack() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_pack($database) { $return_dbase_pack = false; // ========== DBASE_PACK - BEGIN // ===== ABOUT // Packs a database // ===== DESCRIPTION // Packs the specified database by permanently deleting all records marked for deletion using dbase_delete_record(). Note that the file will be truncated after successful packing (contrary to dBASE III's PACK command). // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_pack(resource $database): bool // ===== CODE $return_dbase_pack = dbase_pack( $database // resource database - The database resource, returned by dbase_open() or dbase_create(). ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 Emptying a dBase database // [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); // } // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-pack.php // ========== DBASE_PACK - END // SYNTAX: // bool dbase_pack(resource $database) return $return_dbase_pack; // bool } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_PACK // ============================== // ============================== BEGIN // PHP_DATABASE_VENDOR_DBASE_DBASE_REPLACE_RECORD // ============================== PUBLIC // ============================== ABOUT // Replaces a record in a database. // ============================== SUPPORT // PHP_5_3_0, dbase_7 // ============================== USING FUNCTIONS (1) // dbase_replace_record() - PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ============================== CODE function php_database_vendor_dbase_dbase_replace_record($database, $data, $number) { $return_dbase_replace_record = false; // ========== DBASE_REPLACE_RECORD - BEGIN // ===== ABOUT // Replaces a record in a database // ===== DESCRIPTION // Replaces the given record in the database with the given data. // ===== SUPPORTED // PHP_5 < PHP_5_3_0, dbase_5, dbase_7 // ===== SYNTAX // dbase_replace_record(resource $database, array $data, int $number): bool // ===== CODE $return_dbase_replace_record = dbase_replace_record( $database, // resource database - The database resource, returned by dbase_open() or dbase_create(). $data, // array data - An indexed array of data. The number of items must be equal to the number of fields in the database, otherwise dbase_replace_record() will fail. // Note: If you're using dbase_get_record() return value for this parameter, remember to reset the key named deleted. $number // int number - An integer which spans from 1 to the number of records in the database (as returned by dbase_numrecords()). ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // dbase 7.0.0 - database is now a resource instead of an int. // // [examples] // Examples // [example] // Example #1 Updating a record in the database // [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'); // // // convert the row to an indexed array // $row = array_values($row); // // // Replace the record // dbase_replace_record($db, $row, 1); // dbase_close($db); // } // // [/php] // [/example] // [/examples] // // Notes // Note: Boolean fields result in an int element value (0 or 1) when retrieved via dbase_get_record() or dbase_get_record_with_names(). If they are written back, this results in the value becoming 0, so care has to be taken to properly adjust the values. // ===== LITERATURE_SOURCES // * PHP_NET (2024-04-02) // URL: https://www.php.net/manual/en/function.dbase-replace-record.php // ========== DBASE_REPLACE_RECORD - END // SYNTAX: // bool dbase_replace_record(resource $database, array $data, int $number) return $return_dbase_replace_record; // bool } // ============================== END // PHP_DATABASE_VENDOR_DBASE_DBASE_REPLACE_RECORD // ============================== // ============================== END // PHP_DATABASE_VENDOR_DBASE // ============================== ?>