oscarotero / simple-crud

PHP library to provide magic CRUD in MySQL/Sqlite databases with zero configuration
MIT License
242 stars 58 forks source link

Compare two floats column incorrect #46

Closed darkvovich closed 2 years ago

darkvovich commented 2 years ago
Status Sum (float) Paid (float)
0 115627 115627
$whereArr = [];
$whereArr['status] = 0;
$whereArr[] = "paid > 0 AND paid >= sum";
$query = $db->orders->select()->whereEquals($whereArr)->get();

This example of compare two float fields return empty.

oscarotero commented 2 years ago

This is not a problem of simple-crud, but something related with mysql. See this issue: https://stackoverflow.com/questions/2567434/mysql-floating-point-comparison-issues Perhaps, instead of float you should use decimal for these fields.

darkvovich commented 2 years ago

Thx