PHP code example of chvila / php-xbase

1. Go to this page and download the library: Download chvila/php-xbase library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chvila / php-xbase example snippets


$ composer 
 php


use XBase\Table;

$table = new Table(dirname(__FILE__).'/test.dbf');

while ($record = $table->nextRecord()) {
    echo $record->my_column;
}
 php
$table = new Table(dirname(__FILE__).'/test.dbf', null, 'CP1251');
 php


use XBase\Table;

$table = new Table(dirname(__FILE__).'/test.dbf', array('my_column', 'another_column'));

while ($record = $table->nextRecord()) {
    echo $record->my_column;
    echo $record->another_column;
}
 php
while ($record = $table->nextRecord()) {
    echo $record->getChar('my_column');
    echo $record->getDate('another_column');
}
 php


use XBase\WritableTable;

$table = new WritableTable(dirname(__FILE__).'/test.dbf'));
$table->openWrite();

for ($i = 0; $i < 10; $i++) {
    $record = $table->nextRecord();
    $record->field = 'string';
    $table->writeRecord();
}

# optional
$table->close();