error because migrating to ubuntu

im migrating from windows to ubuntu…

i installed my yii and run my program.it is ok until i try to login / perform action which is related to models

i found this error …




PHP Error

Description


PDO::__construct() [<a href='pdo.--construct'>pdo.--construct</a>]: [2002] Invalid argument (trying to connect via unix://)

Source File


/opt/lampp/htdocs/yii-1.1.5.r2654/framework/db/CDbConnection.php(310)


00298:      * @since 1.0.4

00299:      */

00300:     protected function createPdoInstance()

00301:     {

00302:         $pdoClass='PDO';

00303:         if(($pos=strpos($this->connectionString,':'))!==false)

00304:         {

00305:             $driver=strtolower(substr($this->connectionString,0,$pos));

00306:             if($driver==='mssql' || $driver==='dblib')

00307:                 $pdoClass='CMssqlPdoAdapter';

00308:         }

00309:         return new $pdoClass($this->connectionString,$this->username,

00310: $this->password,$this->_attributes);

00311:     }

00312: 

00313:     /**

00314:      * Initializes the open db connection.

00315:      * This method is invoked right after the db connection is established.

00316:      * The default implementation is to set the charset for MySQL and PostgreSQL database connections.

00317:      * @param PDO $pdo the PDO instance

00318:      */

00319:     protected function initConnection($pdo)

00320:     {

00321:         $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

00322:         if($this->emulatePrepare && constant('PDO::ATTR_EMULATE_PREPARES'))


Stack Trace


#0 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/db/CDbConnection.php(310): PDO->__construct()

#1 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/db/CDbConnection.php(261): CDbConnection->createPdoInstance()

#2 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/db/CDbConnection.php(242): CDbConnection->open()

#3 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/db/CDbConnection.php(221): CDbConnection->setActive()

#4 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/base/CModule.php(372): CDbConnection->init()

#5 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/base/CApplication.php(406): CWebApplication->getComponent()

#6 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/db/ar/CActiveRecord.php(589): CWebApplication->getDb()

#7 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/db/ar/CActiveRecord.php(2167): ProductIntegration->getDbConnection()

#8 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/db/ar/CActiveRecord.php(353): CActiveRecordMetaData->__construct()

#9 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/CActiveDataProvider.php(63): model()

#10 /opt/lampp/htdocs/integrated_system/protected/controllers/ProductIntegrationController.php(147): CActiveDataProvider->__construct()

#11 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/actions/CInlineAction.php(57): ProductIntegrationController->actionIndex()

#12 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/CController.php(300): CInlineAction->run()

#13 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/filters/CFilterChain.php(133): ProductIntegrationController->runAction()

#14 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/filters/CFilter.php(41): CFilterChain->run()

#15 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/CController.php(1084): CAccessControlFilter->filter()

#16 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/filters/CInlineFilter.php(59): ProductIntegrationController->filterAccessControl()

#17 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/filters/CFilterChain.php(130): CInlineFilter->filter()

#18 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/CController.php(283): CFilterChain->run()

#19 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/CController.php(257): ProductIntegrationController->runActionWithFilters()

#20 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/CWebApplication.php(324): ProductIntegrationController->run()

#21 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/web/CWebApplication.php(121): CWebApplication->runController()

#22 /opt/lampp/htdocs/yii-1.1.5.r2654/framework/base/CApplication.php(135): CWebApplication->processRequest()

#23 /opt/lampp/htdocs/integrated_system/index.php(13): CWebApplication->run()




i don’t know how to fix this,i think yii can’t open connection

please help me

thanks

In your config, try to set the database host to ‘127.0.0.1’ instead of localhost.

woahhhhh

great…

thanks yii

The problem is you are now connecting through tcp which is slower than unix socket (well, if you have a high load). Check out this topic: http://www.yiiframework.com/forum/index.php?/topic/6554-database-connection-issue/