![]() |
Safe MySQL Parse Function
This is the function I use when constructing MySQL statements. It allows you to pass in any argument into the function and it will return it back to you all nice and safe.
As the function automatically quotes strings for you, there's no need to quote them in your statement. So for a string I wouldn't need to add the quotes around %s. It would be like so: php Code:
The same goes for integers. The function, however, won't add quotes to an integer. The function even checks for the presence of the ever-annoying GPC, and acts accordingly based on its state. php Code:
|
I think it's a fair start, but is far from ideal.
Take for example the following test page: php Code:
Which produces: Code:
(string) "test" string(6) "'test'"myColumn = '' might work if you want false rows when myColumn is BIT/BOOL but shouldn't you query for TRUE/FALSE or at least 1/0? |
You're quite right, I've not actually tested it so far but I shall be doing some further testing before I implement it into another system.
|
| All times are GMT. The time now is 10:11 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0