How to setup mysqli in Yii

Hello i am a newbie in yii framework.

Can any one help me, how to use mysqli instead of mysql in Yii framework.

What are the steps we need to check, if we want to convert from mysql to mysqli. I have looked into config/main.php and there its showing mysql connection code like this:-




		// uncomment the following to use a MySQL database

		

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=mydbname',

			'emulatePrepare' => true,

			'username' => 'username',

			'password' => 'password',

			'charset' => 'utf8',

		),

]



If anyone know how to enable this please help me.

Thanks in advance.

Neither mysql nor mysqli extension is supported by Yii. It uses PDO instead. No need to worry about it, PDO works perfectly well with MySQL databases, just make sure it’s installed on your system.

Thank you phtamas.

I saw that in a blog like this:-

Here is the url : http://www.phpclasses.org/blog/post/153-The-Plot-to-Kill-PHP-MySQL-Extension.html

Will this affect in Yii concepts, this was the source of my doubt. Am i right or not, please advice?

phamas,

I saw this article too but fear not as S Dev said before - yii uses PDO to interact with the database.

In general, PDO is the preferred method, since it provides a unified data access to multiple db engine layers not just for MySQL, but can work with Postgres, Microsoft, Oracle etc.

PDO is flexible…

[color=#1C2837][size=2][color=#008800]‘connectionString’[/color][color=#000000] [/color][color=#666600]=>[/color][color=#000000] [/color][color=#008800]‘mysql:host=localhost;dbname=mydbname’[/color][color=#666600],[/color][/size][/color]

[color=#1C2837][size=2][color=#008800]‘connectionString’[/color][color=#000000] [/color][color=#666600]=>[/color][color=#000000] [/color][color=#008800]‘pgsql:host=localhost;dbname=mydbname’,‘pass’[/color][color=#666600],[/color][/size][/color]

So to put simple, you are OK. Just use the connection as you have it.

Thanks a lot for your advice :)

I actually worry because of one simple but important thing.

What about performance? If you’re going to build an all-mysql site, and so you don’t need PDO abstraction, isn’t PDO slower than mysqli?

Simple benchmarks seem to show that PDO is slower. I ran one myself, that i found around the web, and it shows that PDO is at least 2 times slower than mysqli.