Re: Automatic coercion when reading string database data
On Tuesday, 12 June 2012 04:31:48 UTC+2, Brad Koch wrote:
I'm currently facing an issue regarding the data types being read from the database. Regardless of the type specified in the schema definition, all data is read in as a string. It's a well documented issue. The encoding of numbers as strings wrecks general havoc when it gets converted to JSON and hits the client side code.My intended solution is to write a behavior that utilizes Model::_schema to automatically sanitize the results. However, I don't want to go out and reinvent the wheel if there's a solution out there I don't know about yet.Is anyone aware of a CakePHP framework feature / library that correctly sanitizes the database input?
You can use a simple function like this:
All the data coming out of the db is a string - becuase that's how mysql returns it.
AD
-- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home