Skip to content

Commit 66b96e0

Browse files
committed
Delete record example
1 parent d5ef646 commit 66b96e0

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ $ composer require hisamu/php-xbase
1313
Sample usage
1414
-----
1515
``` php
16-
<?php
17-
1816
use XBase\Table;
1917

2018
$table = new Table(dirname(__FILE__).'/test.dbf');
@@ -38,8 +36,6 @@ Performance
3836
You can pass an array of the columns that you need to the constructor, then if your table has columns that you don't use they will not be loaded. This way the parser can run a lot faster.
3937

4038
``` php
41-
<?php
42-
4339
use XBase\Table;
4440

4541
$table = new Table(dirname(__FILE__).'/test.dbf', array('my_column', 'another_column'));
@@ -65,8 +61,6 @@ Writing Data
6561
To open a table for writing, you have to use a `WritableTable` object, as on this example:
6662

6763
``` php
68-
<?php
69-
7064
use XBase\WritableTable;
7165

7266
$table = new WritableTable(dirname(__FILE__).'/test.dbf');
@@ -82,6 +76,23 @@ for ($i = 0; $i < 10; $i++) {
8276
$table->close();
8377
```
8478

79+
Delete record
80+
-----
81+
82+
``` php
83+
use XBase\WritableTable;
84+
85+
$table = new WritableTable('file.dbf');
86+
$table->openWrite();
87+
while ($record = $table->nextRecord()) {
88+
if ($record->getBoolean('delete_this_row')){
89+
$table->deleteRecord(); //mark record deleted
90+
}
91+
}
92+
$table->pack(); //save
93+
$table->close();
94+
```
95+
8596
Troubleshooting
8697
-----
8798

0 commit comments

Comments
 (0)