Skip to content

Commit b1dc3c5

Browse files
committed
update changelog
1 parent c4b1490 commit b1dc3c5

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,27 @@ $ composer require hisamu/php-xbase
1818

1919
Sample usage
2020
-----
21+
More samples in `tests` folder.
22+
2123
``` php
2224
use XBase\Table;
2325

24-
$table = new Table(dirname(__FILE__).'/test.dbf');
26+
$table = new Table('test.dbf');
2527

2628
while ($record = $table->nextRecord()) {
29+
echo $record->get('my_column');
30+
//or
2731
echo $record->my_column;
2832
}
2933
```
3034

3135
If the data in DB is not in UTF-8 you can specify a charset to convert the data from:
3236

3337
``` php
34-
$table = new Table(dirname(__FILE__).'/test.dbf', null, 'CP1251');
38+
$table = new Table('test.dbf', null, 'CP1251');
3539
```
3640

37-
It is also possible to read Memos from dedicated files. Just make sure that *.fpt* file with the same name as main database exists
41+
It is also possible to read Memos from dedicated files. Just make sure that *.fpt* file with the same name as main database exists.
3842

3943
Performance
4044
-----
@@ -44,7 +48,7 @@ You can pass an array of the columns that you need to the constructor, then if y
4448
``` php
4549
use XBase\Table;
4650

47-
$table = new Table(dirname(__FILE__).'/test.dbf', ['my_column', 'another_column']);
51+
$table = new Table('test.dbf', ['my_column', 'another_column']);
4852

4953
while ($record = $table->nextRecord()) {
5054
echo $record->my_column;
@@ -69,17 +73,21 @@ To open a table for writing, you have to use a `WritableTable` object, as on thi
6973
``` php
7074
use XBase\WritableTable;
7175

72-
$table = new WritableTable(dirname(__FILE__).'/test.dbf');
73-
$table->openWrite();
76+
$table = new WritableTable('test.dbf');
7477

7578
for ($i = 0; $i < 10; $i++) {
7679
$record = $table->nextRecord();
80+
81+
$record->set('field', 'string');
82+
//or
7783
$record->field = 'string';
84+
7885
$table->writeRecord();
7986
}
8087

81-
# optional
82-
$table->close();
88+
$table
89+
->save()
90+
->close();
8391
```
8492

8593
Delete record
@@ -89,14 +97,17 @@ Delete record
8997
use XBase\WritableTable;
9098

9199
$table = new WritableTable('file.dbf');
92-
$table->openWrite();
100+
93101
while ($record = $table->nextRecord()) {
94-
if ($record->getBoolean('delete_this_row')){
102+
if ($record->get('delete_this_row')) {
95103
$table->deleteRecord(); //mark record deleted
96104
}
97105
}
98-
$table->pack(); //save
99-
$table->close();
106+
107+
$table
108+
->pack() //remove deleted rows
109+
->save() // save changes
110+
->close();
100111
```
101112

102113
Troubleshooting

0 commit comments

Comments
 (0)