I have to move a WebSite to PHP 5.6. Therefore, I need to change the way PHP connects to MySQL from the mysql_-like-type to either PDO or mysqli.
Someone proposed to write a wrapper (class), so that the old way of using
$db = mysql_connect("localhost", "testusr", "secretpass");
mysql_select_db("testdb", $db);
becomes
$db = new PDO("mysql:host=localhost;dbname=testdb", "testusr", "secretpass");
Apart from the connection, I have only basic SQL queries like INSERT, SELECT and DELETE.
Is there already such a thing that "translates" old mysql_ queries to mysqli or PDO?
It could maybe look like this:
function mysql_connect_wrapper ($host, $user, $pwd) {
$db = new PDO("mysql:host=localhost;dbname=testdb", "testusr", "secretpass");
return $db;
}
$db = mysql_connect_wrapper("localhost", "testusr", "secretpass");
Thanks a lot!