Hot answers tagged


Minor stuff: your backticks are distracting, and unnecessary in most (all?) cases. I'd delete them. Your use of TRUNCATE seems like a formatting concern and not a query concern. I'd expect that a query like this just return a full, floating-point number, and leave it up to the application as to whether rounding or truncation needs to be performed.


Your code is good enough at preventing sql injection. But it sucks (pardon me) in everything else. Don't print database error to the user. Don't put echoes into your logic. Don't double last letters of post fields names. Don't repeat yourself by integrating your database connection to every class that has nothing to do with db. Prefer composition. User ...


Please don't ever perform surgery on a JSON string. I see that you are trying to flatten your multidimensional indexed array of indexed arrays into an indexed array. This is far simpler, more stable, and more professionally done in your loop. First, if you are not retaining the table column name as the key in your result array, then don't call fetchAssoc(); ...

Only top voted, non community-wiki answers of a minimum length are eligible