luads / php-xbase

A simple parser for *.dbf files using PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong number recorded

rtfmfm opened this issue · comments

Hi! I have the following problem.
This is my sql database table:

| id | record_id | from | num | qty | qty2 | to |
| 150 | 34 | 111 | 200006 | 555.000 | 5550.000 | 222 |

When I try to write this data in dbf the value of the column qty2 is inserted as 5.000. The problem is present when the value is more than 999.000 (has 4 numbers before the decimal). If the value is 9000.000 it is written as 9.000. The script is taking only the first digit of the number. The header (with type) of the dbf colum qty2 is qty,N,14,3

I'm using this code to write the dbf:

$table = new WritableTable($files_path.'/file.dbf', null, 'CP1251');
$table->openWrite();
$lines = Records::all();
foreach ($lines as $line) {
$record = $table->appendRecord();
$record->from = $line->from;
$record->num = $line->num;
$record->qty = $line->qty;
$record->qty2 = $line->qty2;
$record->to = $line->to;
$table->writeRecord();
}
$table->close();

Any advice on how to solve this will be much appreciated. Thank you!

I found something. I opened the dbf with linux dbfviewer and found that the numbers are written but there is an comma sign which is dividing thousands. The number is written as 5,550.000 instead of 5555.000 and the software (windows client and Libreoffice in Linux) is showing it as 5,000

Can you tell me where to change this thousands separator, please?

Nevermind... found it.