Page 1 of 1

use mysqli or PDO

PostPosted: 04. December 2014 05:43
by tovindra
I got this error whenever i run my program. "mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in c:\xamp......."

Re: use mysqli or PDO

PostPosted: 04. December 2014 06:03
by JJ_Tagy
Since I don't see a question, I assume you think something is wrong. This is just a warning, but I recommend switching to mysqli ("i" being "improved"). http://php.net/manual/en/mysql.php

Re: use mysqli or PDO

PostPosted: 04. December 2014 07:23
by Altrea
I (and most php professionals) recommend switching to PDO, because:
  • it can do everything mysqli can do too, and more
  • it has a far better error handling (option to use exceptions)
  • it has the advantage to switch the database driver if needed. So if you need to switch from MySQL to Oracle, MS SQL, PostgreSQL, SQLite, ..., you can do this with a minimum of changes
  • it can use named parameters
  • It has an OOP syntax only
  • [...]

But the syntax of PDO is more different to mysql than mysqli is

If your question is, if you have to change to provide your application is running even on future php versions, than the answer is yes. You only need to choose which one you prefer.