2011-03-11 121 views
4

即時嘗試將sqlite設置爲輔助適配器並且遇到問題。Zend Db SQLITE設置

我收到以下消息:

Message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'reports.reports' doesn't exist 

我對錶的代碼是:

class Table_Reports extends Zend_Db_Table_Abstract { 
protected $_name = 'reports'; 
protected $_id = 'report_id'; 
protected $_rowClass = 'Model_Report'; 
protected $_adapter = 'dbReports'; 
protected $_schema = 'reports'; 

}

如果我改變$ _schema空白,然後它會嘗試使用我的主要mysql數據庫。

我的應用程序配置爲:

resources.multidb.db1.adapter = "PDO_MYSQL" 
resources.multidb.db1.host = "localhost" 
resources.multidb.db1.dbname = "test" 
resources.multidb.db1.username = "root" 
resources.multidb.db1.password = "" 
resources.multidb.db1.isDefaultTableAdapter = true 

resources.multidb.db2.adapter = "PDO_SQLITE" 
resources.multidb.db2.dbname = ROOT "/data/reports.db" 

任何人都知道怎麼回事?

$reports = new Table_Reports(); 
$reportRow = $reports->createRow(); 
+0

請嘗試[打開查詢分析](http://framework.zend.com/manual/en/zend.db.profiler.html),這將使您能夠獲得實際執行的SQL。從那以後,我們可以確定究竟出了什麼問題。我會推測,當它不應該運行時,ALTER TABLE正在運行。 – Charles 2011-03-11 21:04:09

回答

0

我設法排除這個問題。

使用MySQL的用戶名和密碼信息嘗試連接到SQLite的,所以我不得不強制適配器適配器這樣修改過來:

public function __construct($config = array()) 
{ 
    $this->_setAdapter(Zend_Registry::get('dbReports')); 
    parent::__construct($config); 
} 

這是文件中class Table_Reports

2

嘗試使用APPLICATION_PATH和相對路徑,而不是ROOT:

感謝

我已經打開了剖析但據我可以告訴什麼,當我運行發生錯誤被查詢。也許你有open_basedir限制或授權問題