2013-12-19 54 views
1

我正在嘗試學習Yii,但是當我使用yiic時,我遇到了一個非常持久的錯誤。 第一個系統詳細信息:Ubuntu 13.04與apache2,php 5.5.3和mysql 5.5.3。 我運行/yiic migrate由於沒有找到pdo_mysql驅動程序而導致的Yiic遷移錯誤

裏面/保護我正在開發的webapp。

我得到的錯誤:

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /var/www/yii/framework/db/CDbConnection.php:382 

這似乎是因爲在CDbConnection.php,如果安裝pod_mysql腳本檢查的382線,但無法找到它。

`if($this->_pdo===null) 
{ 
    if(empty($this->connectionString)) 
     throw new CDbException('CDbConnection.connectionString cannot be empty.'); 
    try 
    { 
     Yii::trace('Opening DB connection','system.db.CDbConnection'); 
     $this->_pdo=$this->createPdoInstance(); 
     $this->initConnection($this->_pdo); 
     $this->_active=true; 
    } 
    catch(PDOException $e) 
    { 
     if(YII_DEBUG) 
     { 
      throw new CDbException('CDbConnection failed to open the DB connection:'. 

            $e->getMessage(),(int)$e->getCode(),$e->errorInfo); 

     } 
     else 
     {           
      Yii::log($e->getMessage(),CLogger::LEVEL_ERROR,'exception.CDbException'); 

      throw new CDbException('CDbConnection failed to open the DB connection.' 

            ,(int)$e->getCode(),$e->errorInfo); 
    } 
    } 
} 

^^這是相關的代碼片段。

運行

php -i|grep PDO gives 
PDO 
PDO support => enabled 
PDO drivers => sqlite 
PDO Driver for SQLite 3.x => enabled 

的結果所以我的問題似乎只有sqlite的驅動程序正在運行。但是,我確保檢查php-mysql是否已安裝(因爲pdo_mysql已被棄用且位於此包中)。我已經跑出了想要做什麼的想法,並會很感激任何和所有的幫助!

在此先感謝!

回答

2

控制檯應用程序有自己的配置存儲在protected/config/console.php。請確保你已經配置了一個數據庫組件。

+0

我已經設置了console.php的DB組件在配置我已經設置它以同樣的方式在main.php中,我可以驗證webapp可以創建,讀取和更新數據庫。除了不能使用yiic migrate ... – user3120781

+0

什麼是您的操作系統? – DaSourcerer

+0

Ubuntu 13.04在虛擬框中 – user3120781

0

此問題來自於您的phpcli.ini而不是php.ini。phpcli.ini你應該增加:

extension=php_pdo_mysql.dll 

php.ini中

相關問題