Zendframeworkclass initialization & lt ;? PhpclassDbextendsZend_Db_Table {function _ construct ($ name, $ primary) {echo & quot; ****** $ name ****** & quot ;;} publicfunctionsetName (zend framework class initialization problem
Class Db extends Zend_Db_Table {
Function _ construct ($ name = '', $ primary = ''){
Echo "****** $ name ******";
}
Public function setName ($ name ){
$ This-> _ name = $ name;
}
Public function setPrimary ($ primary ){
$ This-> _ primary = $ primary;
}
}
Function indexAction (){
$ ArtiClass = new Db ('B _ arti_class', 'id ');
}
Result
***********
Catchable fatal error: Argument 1 passed to Zend_Db_Select ::__ construct () must be an instance of Zend_Db_Adapter_Abstract, null given, called in D: \ Soft \ wamp \ www \ library \ Zend \ Db \ Table \ Select. php on line 76 and defined in D: \ Soft \ wamp \ www \ library \ Zend \ Db \ Select. php on line 163
------ Solution --------------------
In the inheritance class of zend_db_table, it is better not to use the constructor. use another method similar to the constructor.
Protected function _ setup ()
{
$ This-> _ name = 'Category ';
Parent: _ setup ();
}
------ Solution --------------------
If you must use the constructor, remember to call the constructor of the parent class in the subclass.
Public function _ construct ($ name, $ primary)
{
$ This-> _ name = $ name;
$ This-> _ primary = $ primary;
Parent: :__ construct ();
}