Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Bug #620 limit: No Valid Arguments (for float, double and real)
Submitted: 2004-01-24 13:05 UTC
From: maka3d at yahoo dot com dot br Assigned: alan_k
Status: Closed Package: DB_DataObject
PHP Version: Irrelevant OS: irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2004-01-24 13:05 UTC] maka3d at yahoo dot com dot br
Description: ------------ if call $db_dataObject->limit((double)2,10) error limit: No Valid Arguments is raised dataObject.php at line 659 should check if the real, float and double value are integer. patch: if ((!is_int($a) && ((string)((int)$a) !== (string)$a))

Comments

 [2004-01-26 10:37 UTC] alan_k
float and double values are not valid values? - most databases will bork horribly (I would have thought if you send it) selecT * from xxx limit 2.0 , 10 I dont think accepting doubles/floats would be a good idea. even if it casted them to int's, it would infer rather unpredictable behaviour...
 [2004-01-26 11:45 UTC] maka3d at yahoo dot com dot br
I agree that calling limit 2.0, 10 is horrible. But what you are doing is a type checking, not a value checking. PHP is not strong typing but you are forcing it. You have to check if the number is an integer, not if it's of type int. As you did after && checking if the string is a valid number. What I'm proposing is to check(like you check for string) if the input is a valid number. Doing this: if ((!is_int($a) && ((string)((int)$a) !== (string)$a)) you accept double and float values like 2.0, 3.0 but raise an error if the value is 2.1, 2.4 or "2.6" ... Remember, don't do type checking, do value checking. Don't kill the PHP natural behavior.
 [2004-01-26 13:07 UTC] alan_k
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. Got it :) - yeah - that makes sense now :) Thanks Alan