我遵循:http://framework.zend.com/manual/en/learning.quickstart.create-model.html。主鍵列(s)(id)不在此表中的列()
在問題發生之後繼續打牆。我現在一個是以下錯誤:
An error occurred
Application error
Exception information:
Message: Primary key column(s) (id) are not columns in this table()
Stack trace:
#0 C:\wamp\www\zendtest\quickstart\library\Zend\Db\Table\Abstract.php(982): Zend_Db_Table_Abstract->_setupPrimaryKey()
#1 C:\wamp\www\zendtest\quickstart\library\Zend\Db\Table\Select.php(100): Zend_Db_Table_Abstract->info()
#2 C:\wamp\www\zendtest\quickstart\library\Zend\Db\Table\Select.php(78): Zend_Db_Table_Select->setTable(Object(Application_Model_DbTable_Guestbook))
#3 C:\wamp\www\zendtest\quickstart\library\Zend\Db\Table\Abstract.php(1018): Zend_Db_Table_Select->__construct(Object(Application_Model_DbTable_Guestbook))
#4 C:\wamp\www\zendtest\quickstart\library\Zend\Db\Table\Abstract.php(1326): Zend_Db_Table_Abstract->select()
#5 C:\wamp\www\zendtest\quickstart\application\models\GuestbookMapper.php(58): Zend_Db_Table_Abstract->fetchAll()
#6 C:\wamp\www\zendtest\quickstart\application\controllers\GuestbookController.php(14): Application_Model_GuestbookMapper->fetchAll()
#7 C:\wamp\www\zendtest\quickstart\library\Zend\Controller\Action.php(516): GuestbookController->indexAction()
#8 C:\wamp\www\zendtest\quickstart\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('indexAction')
#9 C:\wamp\www\zendtest\quickstart\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#10 C:\wamp\www\zendtest\quickstart\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#11 C:\wamp\www\zendtest\quickstart\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#12 C:\wamp\www\zendtest\quickstart\public\index.php(26): Zend_Application->run()
#13 {main}
Request Parameters:
array (
'controller' => 'guestbook',
'action' => 'index',
'module' => 'default',
)
但我相信我的表中有一個主鍵ID爲表:
CREATE TABLE guestbook (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
email VARCHAR(32) NOT NULL DEFAULT '[email protected]',
comment TEXT NULL,
created DATETIME NOT NULL
);
CREATE INDEX "id" ON "guestbook" ("id");
不明白爲什麼收到錯誤。
我怎麼能看它是否甚至拿起正確的數據庫
檢查列名後面的尾部空格,並請發出查詢'SHOW CREATE TABLE guestbook'的輸出,這樣我們可以仔細檢查實際結構 – 2012-08-14 15:10:38
我們再次見面時如何顯示出輸出的cmd promt – 2012-08-14 15:36:45
! :) ...由於您使用的是wamp,因此您必須在系統上安裝phpmyadmin。轉到http:// localhost/phpmyadmin,在那裏你可以看到左側的所有數據庫,點擊你的數據庫。然後,將會有一個名爲SQL的選項卡,您可以將@TimFountain的命令放在那裏,並告訴我們輸出的內容是什麼......另外,請確保您在表格中有一些數據:) – Karma 2012-08-14 16:17:20