How to enable PDO MySQL extension in yii?

I’m using yii1.1.5 and EasyPHP 5.3.2. I’m not able to use the Model Generator in Yii as it requires the PDO MySQL extension or PDO SQLite extension. Could any1 tell me how to enable either of them in EasyPHP. I did lots of research and i found that i need to edit my PHP.ini file. However when i edit it, there’s no change at all. Is there any other files that i need to edit?

I enabled the following by removing the semi colon in the PHP.ini:

extension=php_pdo_firebird.dll

extension=php_pdo_mssql.dll

extension=php_pdo_mysql.dll

extension=php_pdo_oci.dll

extension=php_pdo_odbc.dll

extension=php_pdo_pgsql.dll

extension=php_pdo_sqlite.dll

What other changes do i need to do in order to be able to use the Model Generator in Yii?

when you edit the php.ini you need to restart the apache

after that check the Yii requirements to see if it’s OK

I restarted the server after editing. But, Yii Requirements are still the same.

I still get the warning in PDO SQLite and PDO MySQL extensions

Any other solutions?

check that you edited the right php.ini… in easyphp you can use the easy icon on the taskbar -> right click -> configuration

When i enable them through right click -> configuration -> PHP extensions, php_pdo_oci is in red and when i restart the server i get the following error messages twice:

This applciation has failed to start because OCI.dll was not found. Re-installing the application may fix this problem.

PHP Startup: Unable to load dynamic library ‘C:\easyphp\php\ext\php_pdo_oci.dll’ - The specified module could not be found.

Please help!

Are you sure you have all those uncommented libraries installed? For me is very clear the description of the error.

Go and check the libraries in C:\easyphp\php\ext\

OCI is for oracle… this one you can comment out (php_pdo_oci.dll) so to not get these errors…

Yes i already checked all the libraries are there including php_pdo_oci.dll.

I didnt enable php_pdo_oci.dll and enabled the other required libraries, then my requirements have changed. PDO SQLite and PDO MySQL extensions have now passed. however i’m still not able to use the model generator because when i click on it takes too much time and displays the following error messages:

Fatal error: Maximum execution time of 30 seconds exceeded in C:\easyphp\www\yii\framework\db\CDbConnection.php on line 0

Is this because i didnt check php_pdo_oci.dll?

How can i make php_pdo_oci.dll not appear in red?

php_pdo_oci is not required if you don’t need oracle database…

in fact if you use only mysql… then you need only PDO for mysql…

The error you get is something else… have you created a database with some tables in mysql? have you edited config.php with appropriate data for connection to the database (connectionstring, username, password) ?

The application that i created already contains a table(tbl_user)

Main.php contains the following:

‘db’=>array(

		'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',


	),


	


	// uncomment the following to use a MySQL database


	


	'db'=>array(


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


		'emulatePrepare' => true,


		'username' => 'root',


		'password' => '',


		'charset' => 'utf8',


	),

When i click on Model Generator i get the following:

CDbException

Description

CDbConnection failed to open the DB connection: SQLSTATE[42000] [1049] Unknown database ‘testdrive.db’

Source File

C:\easyphp\www\yii\framework\gii\generators\model\ModelCode.php(52)

00040: ));

00041: }

00042:

00043: public function requiredTemplates()

00044: {

00045: return array(

00046: ‘model.php’,

00047: );

00048: }

00049:

00050: public function init()

00051: {

00052: if(Yii::app()->db===null)

00053: throw new CHttpException(500,‘An active “db” connection is required to run this generator.’);

00054: $this->tablePrefix=Yii::app()->db->tablePrefix;

00055: parent::init();

00056: }

00057:

00058: public function prepare()

00059: {

00060: $this->files=array();

00061: $templatePath=$this->templatePath;

00062:

00063: if(($pos=strrpos($this->tableName,’.’))!==false)

00064: {

Stack Trace

#0 C:\easyphp\www\yii\framework\db\CDbConnection.php(242): CDbConnection->open()

#1 C:\easyphp\www\yii\framework\db\CDbConnection.php(221): CDbConnection->setActive(true)

#2 C:\easyphp\www\yii\framework\base\CModule.php(372): CDbConnection->init()

#3 C:\easyphp\www\yii\framework\base\CModule.php(86): CModule->getComponent(‘db’)

#4 C:\easyphp\www\yii\framework\gii\generators\model\ModelCode.php(52): CModule->__get(‘db’)

#5 C:\easyphp\www\yii\framework\web\CFormModel.php(40): ModelCode->init()

#6 C:\easyphp\www\yii\framework\gii\CCodeGenerator.php(149): CFormModel->__construct()

#7 C:\easyphp\www\yii\framework\gii\CCodeGenerator.php(61): CCodeGenerator->prepare()

#8 C:\easyphp\www\yii\framework\web\actions\CInlineAction.php(57): CCodeGenerator->actionIndex()

#9 C:\easyphp\www\yii\framework\web\CController.php(300): CInlineAction->run()

#10 C:\easyphp\www\yii\framework\web\CController.php(278): CController->runAction(Object(CInlineAction))

#11 C:\easyphp\www\yii\framework\web\CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)

#12 C:\easyphp\www\yii\framework\web\CWebApplication.php(324): CController->run(’’)

#13 C:\easyphp\www\yii\framework\web\CWebApplication.php(121): CWebApplication->runController(‘gii/model’)

#14 C:\easyphp\www\yii\framework\base\CApplication.php(135): CWebApplication->processRequest()

#15 C:\easyphp\www\demo\index.php(13): CApplication->run()

#16 {main}

2010-12-08 16:12:10 Apache/2.2.14 (Win32) PHP/5.3.2 Yii Framework/1.1.5

I just created the database in MySQL, everything’s is working fine now!! Thanx a lot for your help guys! :D

NOTE: From the code you posted… you have uncommented the mysql config… it would be a good practice to comment the sqllite config then…