不知道是什么原因保存模型时出现错误:
致命错误:调用布尔值上的成员函数 beginTransaction()
该模型如下所示:
class Brain_CrownCaliber_Model_Processcrown extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init('brain_crowncaliber/crown_caliber_process');
}
public function addProductToCrown($idArray)
{
foreach ($idArray as $id) {
$this->setData('product_id', $id);
}
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$this->save();
}
}
我注册它config.xml
:
<models>
<brain_crowncaliber>
<class>Brain_CrownCaliber_Model</class>
<resourceModel>brain_crowncaliber_resource</resourceModel>
</brain_crowncaliber>
</models>
可能是什么问题呢?我什至不知道我在这里做错了什么。
资源部分:
<brain_crowncaliber_resource>
<class>HexBrain_CrownCaliber_Model_Resource</class>
<entities>
<crown_caliber_process>
<table>crown_caliber_process</table>
</crown_caliber_process>
</entities>
</brain_crowncaliber_resource>
资源模型
class Brain_CrownCaliber_Model_Resource_Processcrown extends Mage_Core_Model_Resource_Db_Abstract
{
protected function _construct()
{
$this->_init('brain_crowncaliber/crown_caliber_process', 'process_id');
}
}
我会将其格式化为答案,因为评论不允许正常格式化
这是文件
app/code/core/Mage/Core/Model/Config.php
第 1349 行中的方法做点什么
var_dump($className)
,看看是什么类名形成的,很有可能是错的。我们进一步研究该方法getModelClassName()
,通常我们会到达同一文件的方法 1219 。getGroupedClassName()
此方法的作用是从配置中获取常规部分中指定的类前缀名称
models
,在您看到生成的类名称后,您就会明白错误在哪里。但根据经验,我会说配置中的某处有错字。原则上,CO 上的编辑版本应该可以工作。