Skip to content

1.3.2 WritableTable `editMode` option

Compare
Choose a tag to compare
@gam6itko gam6itko released this 09 Dec 14:13
· 62 commits to master since this release
  • Table::__constructor accepts second argument as an options array. Available options: encoding, columns.
use XBase\Table;

// before 1.3.2
$table = new Table(
    __DIR__.'/Resources/foxpro/1.dbf', 
    ['column1', 'column2'], 
    'cp852'
);

// since 1.3.2
$table = new Table(
    __DIR__.'/Resources/foxpro/1.dbf', 
    [
        'columns' => ['column1', 'column2'], 
        'encoding' => 'cp852'
    ]
);
  • WritableTable editMode option.
    • clone Default. Creates a clone of original file and applies all changes to it. To save changes you need to call save method.
    • realtime Immediately apply changes for original table file. Changes cannot be undone.
use XBase\WritableTable;

// clone edit mode
$tableWrite = new WritableTable(
    'file.dbf', 
    [
        'encoding' => 'cp866',
        'editMode' => WritableTable::EDIT_MODE_CLONE,
    ]
);
// do edits
$tableWrite
    ->save()
    ->close();

// realtime edit mode
$tableWrite = new WritableTable(
    'file.dbf', 
    [
        'encoding' => 'cp866',
        'editMode' => WritableTable::EDIT_MODE_REALTIME,
    ]
);
// do edits
$tableWrite->close();