Hello, I have a perplexing problem that may actually be a PHP problem rather than CakePHP 1.2 (rev 8134) but since the problem appears for me when I am using the Model class methods in CakePHP I'm posting here hoping at least for a few pointers.
The Problem: I read in rows from a csv file with mixed, string, integer, values. The read values are placed in an array and saved to the appropriate table. Everything is working fine except in a few exceptional cases. In some rows there are float values of the form 0.02 or 0.03 etc and the corresponding fields in the MySQL DB to which they should be saved are defined as float(10,2). When I check the INSERT SQL statement generated in debug mode of CakePHP they show as: INSERT ....VALUES (...... -9.50, -0.12, '0.02', -5.63, 2.51, .......)... so all values are interpreted as numbers/floats and the 0.02 seems to be interpreted as a string with ' '. If I manually edit the csv file and change the value from 0.02 to .02 then the equivalent SQL statement is: ...VALUES (..... -9.50, -0.12, .02, -5.63, 2.51, ......) which is correctly interpreted as a float. Similarly if there is a minus sign in front of the number in the csv file e.g. -0.02 then it is interpreted as a float. The INSERT works fine and the row is inserted into the DB table. If I take the same input values and try to SELECT the same row with these values, once again the SQL statement generated is of the form: .... AND `fat_per` = -0.12 AND `protein_per` = '0.02'..... with the ' ' around the 0.02 and it does not find the matching row. Once again if I manually change the 0.02 in the file to .02 then the row is found. I try the PHP function in the same setup: is_float(0.02) and it returns true. Any ideas on what is going wrong here would be appreciated and whether it is really a CakePHP behavior or PHP? I have tried searching different forums but have not found anything specifically describing this problem. Thanks Adrian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
