In cakephp 1.2 we were using mysqli without any error, but I think in cakephp2.0.6 this facility has been removed. Can anybody suggest me how we can use mysqli in cakephp2.0.6.
Following code throwing error.
'datasource' => 'Database/Mysqli',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'dev',
'prefix' => ''
The reason that
Database/Mysqlidoesn’t work as your datasource is thatModel/Datasource/Database/Mysqli.phpdoesn’t exist, and doesn’t need to exist.CakePHP 2.x uses PDO handle database communication. There is little to no reason to use MySQLi over PDO, since PDO gives you access to nearly all of the MySQLi capabilites and more. Named parameter binding alone is reason enough to prefer it over MySQLi, not to mention platform-independence.
That said, the actual driver being used is irrelevant since Cake handles all of the database interactions for you. Unless you have hacked behind Cake’s database abstraction layer in your app, just use
Database/Mysqland your app should work perfectly.In case you’re curious, here’s a short overview of PDO vs MySQLi.