Monday, July 15, 2013

Resolve the PDO disabling issues for Yii on Godaddy hosting

My Yii application uses PDO for database access, which requires the server to have the PDO enabled. However, I am having some problem hosting my Yii application on GoDaddy, since hosting providers suych as GoDaddy disable PDO. After some searching, I found an alternative PHPPDO for Yii, which can be downloaded from:

http://www.yiiframework.com/extension/phppdo/

This extension allow you to use PHP-emulated PDO class on that hostings. The process of including PHPPDO for Yii application is very simple:

Step 1: download and extract the content of PHPPDO to protected/extensions of your Yii application
Step 2: in the protected/config/main.php, commented out the original db connection configuration and replaced with the PHPPDO one, just as in the following:

                /*
'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => $ps_connectionString,
'emulatePrepare' => true,
'username' => $ps_dbusername,
'password' => $ps_dbpassword,
'charset' => 'utf8',
),*/
'db'=>array(
'class'=>'application.extensions.PHPPDO.CPdoDbConnection',
'pdoClass' => 'PHPPDO',
'connectionString' => $ps_connectionString,
'emulatePrepare' => true,
'username' => $ps_dbusername,
'password' => $ps_dbpassword,
'charset' => 'utf8',
),

No comments:

Post a Comment