dqwh1119 2016-05-20 07:24
浏览 64
已采纳

致命错误:未捕获错误:在布尔值上调用成员函数setOrder()

i have try crush Lesson3_Test_Model_Mysql4_Test and Lesson3_Test_Model_Mysql4_Test_Collection after clear setOrder('id_celebes','asc'); but error no detected.______________but if i crush Lesson3_Test_Model_Test after clear setOrder('id_celebes','asc'); i found error page

<?php
class Lesson3_Test_Block_Monblock extends Mage_Core_Block_Template
{
    public function methodblock()
    {
        $retour='';
        /* we are doing the query to select all elements of the celebes table (thanks to our model lesson3/test and we sort them by id */
        $collection = Mage::getModel('lesson3/test')->getCollection()->setOrder('id_celebes','asc');
        /* then, we check the result of the query and with the function getData() */
        foreach($collection as $data)
        {
             $retour .= $data->getData('name').' '.$data->getData('surename').' '.$data->getData('phone').'<br />';
        }
        //i return a success message to the user thanks to the Session.
        Mage::getSingleton('adminhtml/session')->addSuccess('Congratulation !!');
        return $retour;
     }
}
<?xml version="1.0"?>
  <config>
     <modules>
        <Lesson3_Test>
          <version>1.0.0</version>
        </Lesson3_Test>
     </modules>
     <frontend>
       <routers>
          <lesson3>
              <use>standard</use>
              <args>
                 <module>Lesson3_Test</module>
                 <frontName>lesson3</frontName>
              </args>
           </lesson3>
       </routers>
       <layout>
         <updates>
              <lesson3>
                   <file>lesson3.xml</file>
               </lesson3>
          </updates>
      </layout>
    </frontend>
    <global>
      <blocks>
        <lesson3>
          <class>Lesson3_Test_Block</class>
        </lesson3>
      </blocks>
    <models>
        <lesson3>
            <class>Lesson3_Test_Model</class>
            <resourceModel>Lesson3_mysql4</resourceModel>
        </lesson3>
        <lesson3_mysql4>
            <class>Lesson3_Test_Model_Mysql4</class>
            <entities>
                <test>
                    <table>celebes</table>
                </test>
            </entities>
        </lesson3_mysql4>
    </models>
        <!-- allow the plugin to read and write -->
    <resources>
        <!-- connection to write -->
        <lesson3_write>
            <connection>
                <use>core_write</use>
            </connection>
        </lesson3_write>
        <!-- connection to read -->
       <lesson3_read>
          <connection>
             <use>core_read</use>
          </connection>
       </lesson3_read>
    </resources>
    </global>
</config>
<?php
class Lesson3_Test_Model_Test extends Mage_Core_Model_Abstract
{
     protected function _construct()
     {
         parent::_construct();
         $this->_init('lesson3/test');
     }
}
<?php
class Lesson3_Test_Model_Mysql4_Test extends Mage_Core_Model_Mysql4_Abstract
{
     protected function _construct()
     {
         $this->_init('lesson3/test', 'id_celebes');
     }
}
<?php
class Lesson3_Test_Model_Mysql4_Test_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
 {
     protected function _construct()
     {
         parent::_construct();
         $this->_init('lesson3/test');
     }
}
  • 写回答

1条回答 默认 最新

  • douzhan2027 2016-05-21 13:34
    关注

    I found the problem on config

    <resourceModel>Test_mysql4</resourceModel>
    

    I changed it with this

    <resourceModel>test_mysql4</resourceModel>
    

    and works

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?