这是我的问题,有人可以告诉我这个错误吗?我尽可能多地尝试,但仍然无法找到错误......希望能解决它,因为它已经花了我两天的时间来面对这个问题....这太可怕了......
在...中的非对象上调用成员函数load()
我的config.xml
<global>
<models>
<appointment>
<class>Ltsport_Appointment_Model</class>
<resourceModel>appointment_mysql4</resourceModel>
</appointment>
<appointment_mysql4>
<class>Ltsport_Appointment_Model_Mysql4</class>
<entities>
<apptshow>
<table>appt_master</table>
</apptshow>
</entities>
</appointment_mysql4>
</models>
<resources>
<appointment_write>
<connection>
<use>core_write</use>
</connection>
</appointment_write>
<appointment_read>
<connection>
<use>core_read</use>
</connection>
</appointment_read>
我的IndexController.php
<appt_setup>
<setup>
<module>Ltsport_Appointment</module>
<class>Ltsport_Appointment_Model_Resource_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</appt_setup>
</resources>
</global>
<?php
class Ltsport_Appointment_IndexController extends Mage_Core_Controller_Front_Action{
public function indexAction(){
echo "Index!";
}
public function setupAction(){
$params = $this->getRequest()->getParams();
$apptshow = Mage::getModel('appointment/apptshow');
$apptshow->load($params['id']);
$data = $apptshow->getData();
var_dump($data);
}
}
?>`
Apptshow.php at \ Model
<?php
class Ltsport_Appointment_Model_Mysql4_Apptshow extends Mage_Core_Model_Abstract{
protected function _construct()
{
parent::_construct();
$this->_init('appointment/apptshow');
}
}
?>
Apptshow.php在\ Model \ Mysql4 \
<?php
class Ltsport_Appointment_Model_Mysql4_Apptshow extends Mage_Core_Model_Abstract{
protected function _construct()
{
parent::_construct();
$this->_init('appointment/apptshow');
}
}
?>
答案 0 :(得分:0)
\ Model \ Mysql4 \的Apptshow.php应该是一个扩展Mage_Core_Model_Mysql4_Abstract
的资源模型。
class Ltsport_Appointment_Model_Mysql4_Apptshow extends Mage_Core_Model_Mysql4_Abstract{
protected function _construct()
{
parent::_construct();
$this->_init('appointment/apptshow', 'id');
}
}
另请注意,在Magento CE 1.6之后,Mysql4
已被弃用。