Git Product home page Git Product logo

Comments (13)

 avatar commented on June 27, 2024

I think, the problem here is that some users used this code to read the data and some others to write the data. So, what is ok for some ones are not ok to the others. I also can not writing the types B, F and T. I then use N with decimalcount != 0 to write doubles.

from php-xbase.

root-talis avatar root-talis commented on June 27, 2024

@letscape: I am trying to READ data from the cell.

from php-xbase.

wardopdem avatar wardopdem commented on June 27, 2024

Bug in file ...\src\XBase\Record.php, method Record.getObject, line 129:
case self::DBFFIELD_TYPE_NUMERIC:return $this->getInt($column->getName());

Type ('N') may be not only integer (in my case @'N33.4'): need analize this (length/decimalCount properties) and use getFloat/getDouble if it need.

Stuped quick-fix in Record.getInt may be something like that (for debug purposes only!):

// return intval($s);
if (($res = intval($s)) != $s) {
$res = doubleval($s);
}
return $res;

p.s. this bug probably is not connected with @root-talis problem - at the not corrected version get 8.0 at the both rows of the table...

from php-xbase.

wardopdem avatar wardopdem commented on June 27, 2024

See my pull request for more correct desigion.

from php-xbase.

luads avatar luads commented on June 27, 2024

Great, thanks for that. I'm really short on time right now, so I hadn't had a chance to look at this issue.

from php-xbase.

 avatar commented on June 27, 2024

There are another problem when we try to write a dbf here: https://github.com/hisamu/php-xbase/blob/master/src/XBase/Record.php#L295

Is caused by:

 $this->table->getColumn($columnName)

because of this:
https://github.com/hisamu/php-xbase/blob/master/src/XBase/Table.php#L233

The code create an intermediate table (a writableTable) inside the writableTable to write the dbf and is complex to see that the condition can not be satisfy in one of them: https://github.com/hisamu/php-xbase/blob/master/src/XBase/WritableTable.php#L49

Simple fix:

public function setObjectByName($columnName, $value)
    {
        if(array_key_exists($columnName, $this->table->getColumns()))
            return $this->setObject($this->table->getColumn($columnName), $value);
    }

from php-xbase.

 avatar commented on June 27, 2024

This iteration is also inefficient:
https://github.com/hisamu/php-xbase/blob/master/src/XBase/Table.php#L225-L231
but yes is working...

from php-xbase.

wardopdem avatar wardopdem commented on June 27, 2024

Simple fix:

But this is masking problem and this is no good: if the field not found this is a error in client's code - exception need to be thrown (as is) for handling by the caller code - not silent.

from php-xbase.

 avatar commented on June 27, 2024

@wardopdem true, that's why i don't opened a pull request.

from php-xbase.

cerw avatar cerw commented on June 27, 2024

@lestcape is this fixed now? I am getting same error from dev-master

from php-xbase.

 avatar commented on June 27, 2024

@cerw I don't know, my solution was implement a python script (using a python dbf library) to migrate data to an special type of csv where columns headers contains the type and size(like they are display in libreoffice), then I call the script from php to do what i want (read or write data from/to the special csv). As a result, i have support for encoding data automatically. My dbf also can be read by default with VisualFoxPro, without asking for a charset or say that my dbf data is corrupted.

from php-xbase.

 avatar commented on June 27, 2024

I'm trying to simplify my solution, migrating a probed Python library that works. Who want to help is here: https://github.com/lestcape/DbfPHP

from php-xbase.

gam6itko avatar gam6itko commented on June 27, 2024

I don't think it's still relevant

from php-xbase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.