2016-05-20 8 views
0

Ich habe versucht, Lesson3_Test_Model_Mysql4_Test und Lesson3_Test_Model_Mysql4_Test_Collection nach clear setOrder ('id_celebes', 'asc'); but error no detected .______________ aber wenn ich Lesson3_Test_Model_Test nach clear setOrder ('id_celebes','asc ') zerquetsche; i gefunden FehlerseiteSchwerwiegender Fehler: Uncaught Fehler: Aufruf einer Memberfunktion setOrder() on boolean

<?php 
 
class Lesson3_Test_Block_Monblock extends Mage_Core_Block_Template 
 
{ 
 
    public function methodblock() 
 
    { 
 
\t \t $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 */ 
 
\t \t $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> 
 
\t <models> 
 
\t \t <lesson3> 
 
\t \t \t <class>Lesson3_Test_Model</class> 
 
\t \t \t <resourceModel>Lesson3_mysql4</resourceModel> 
 
\t \t </lesson3> 
 
\t \t <lesson3_mysql4> 
 
\t \t \t <class>Lesson3_Test_Model_Mysql4</class> 
 
\t \t \t <entities> 
 
\t \t \t \t <test> 
 
\t \t \t \t \t <table>celebes</table> 
 
\t \t \t \t </test> 
 
\t \t \t </entities> 
 
\t \t </lesson3_mysql4> 
 
\t </models> 
 
\t \t <!-- allow the plugin to read and write --> 
 
\t <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> 
 
\t </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'); 
 
    } 
 
}

+0

Ich vermute, das Problem ist ||||| Lesson3_Test_Model_Mysql4

celebes
||||| denn wenn Aufruftabelle mit |||| $ resource = Mage :: getSingleton ('Kern/Ressource'); $ verbindung = $ resource-> getConnection ('core_read'); $ result = $ verbindung-> abfrage ('select * from celebes') -> fetchAll(); Zend_Debug :: dump ($ result); |||| auf indexController ist dies erfolgreich – gufran

Antwort

0

fand ich das Problem auf Config

<resourceModel>Test_mysql4</resourceModel>

i channge es mit diesem

<resourceModel>test_mysql4</resourceModel>

und seine Arbeit

Verwandte Themen