Zend framework Zend_Db_Table_异常:表必须有主键,但找不到主键
我想使用zend framework在表中插入数据。我有以下表格结构 当我尝试在此表中插入数据时,发现错误Zend framework Zend_Db_Table_异常:表必须有主键,但找不到主键,zend-framework,zend-db,Zend Framework,Zend Db,我想使用zend framework在表中插入数据。我有以下表格结构 当我尝试在此表中插入数据时,发现错误 Zend_Db_Table_Exception: A table must have a primary key, but none was found Primary key column(s) (id) are not columns in this table () 当我在表中指定protected$\u primary='id'时,我发现了错误 Zend_Db_Table
Zend_Db_Table_Exception: A table must have a primary key, but none was found
Primary key column(s) (id) are not columns in this table ()
当我在表中指定protected$\u primary='id'
时,我发现了错误
Zend_Db_Table_Exception: A table must have a primary key, but none was found
Primary key column(s) (id) are not columns in this table ()
我删除了表格,从头开始创建,但一切都是徒劳的。我几个小时以来一直在试图解决这个问题,但一直没有找到任何解决办法
我的模型看起来像
protected $_name = "affiliate_specialities_banners";
//protected $_primary = 'id';
protected $_adapter = null;
public function init() {
$this->_adapter = $this->getAdapter();
}
public function addData($data) {
try {
$id = $this->insert($data);
} catch (Zend_Db_Adapter_Exception $e) {
die($e->getMessage());
}
return $id;
}
请给出任何建议……我猜您使用的是表元数据缓存,因此ZF使用的是不包含主键的较旧版本的表结构。删除缓存文件应该可以解决这个问题。或者,绝对确保它连接到您在phpMyAdmin中查看的数据库。我正在开发一个已经开发的系统。我试图找出缓存存储的位置,但找不到:-(我已经删除了www目录中的所有tmp文件夹,但什么也没有发生。:-(搜索源代码以查找
setDefaultMetadataCache
,这可能会帮助您找到缓存是否正在使用以及在何处使用。)