Can someone recommend some simple and secure PHP/MySQL Database class for the database interaction?
4 Answers
Here at work we use PDO for that kind of things. Clear enough imho
Comments
All extensions (mysql, mysqli, pdo_mysql) are safe, if you use them correctly!
We use PDO, though, which appears to be the easiest one: http://php.net/manual/en/book.pdo.php Just remember to use prepared statements (which are "100% safe" against SQL Injections, when used correctly). If you can't use them, at least use methods like PDO::quote().
2 Comments
Marc B
If used correctly,
$res = exec('echo \'select * from ...\'|mysql -u -pblahblah dbname'); would be safe as well. Preferable? heck no...Explosion Pills
Prepared statements are not "100% safe" against injections. It's hard to say what "used correctly" means. Basically, you have to be careful no matter what you are doing, prepared statements or no.