3 ms·
One step closer to launching mysql_query into the sun.
by astrodust 13y ago
One step closer to launching mysql_query into the sun.
- lhnn 13y agowhy is mysql query bad? as someone who knows sql, I've always loathed over abstracted mechanisms for db calls. its also been a while since I've done web dev.
- unethical_ban 13y agowhy is mysql query bad? as someone who knows sql, I've always loathed over abstracted mechanisms for db calls. its also been a while since I've done web dev.
- krapp 13y agoThe old php mysql_* functions have become notorious for their vulnerability to SQL injection[1]. In no small part because novice developers also have a tendency to build queries directly out of $_GET parameters. While PDO and parameterized queries aren't a silver bullet, simple strings as queries are just a nightmare to do properly.[2] [1] http://stackoverflow.com/questions/60174/how-to-prevent-sql-injection-in-php http://stackoverflow.com/questions/60174/how-to-prevent-sql-... [2] http://www.youtube.com/watch?v=o4dJ7hdA8fs http://www.youtube.com/watch?v=o4dJ7hdA8fs
- lonnyk 13y agoIt's an unmaintained extension that does not support new MySQL functionality. If you don't want any more abstraction you can use the mysqli_* functions instead.
- astrodust 13y agoIf you forget to escape even one bit of supplied user data your entire application, server, or possibly even business can be compromised. You need to be extremely disciplined about escaping if you use this antiquated method. There are automated injection tools that will discover and exploit these, it's not even hard. All you need to do is use a database layer with placeholder values and if you're diligent about encoding everything that way, your chances of being hacked by a simple SQL injection bug are nearly zero. You'll have to make several mistakes before you're in hot water. `mysql_query` is the worst possible interface to MySQL since it's literally the low-level C bindings ported in to PHP without any kind of enhancement. Those functions were intended for writing more abstract interfaces, not being used directly. While it is possible to write mysql_query code correctly, it is very challenging and not worth the time when facilities like PDO exist. Also, if you loathe "over abstracted" database libraries you're probably using the wrong library. A library should make your database interfacing easier, not harder.