Jump to content

[SOLVED] class constructor trouble


simpli

Recommended Posts

Hi,

I am trying to create a class constructor to initialize some properties like this.

class Model_DbTable_Tree extends Zend_Db_Table_Abstract 
{ 
protected $_treePath;

public function __construct()
{
    	$this->$_treePath = new Model_DbTable_CostTreePath();

}

 

I unfortunately get an error

Catchable fatal error: Argument 1 passed to Zend_Db_Select::__construct() must be an instance of Zend_Db_Adapter_Abstract, null given, called in

 

I am working with ZF 1.8. Can anyone point to a possible solution?

 

Thanks,

JR

Link to comment
https://forums.phpfreaks.com/topic/162328-solved-class-constructor-trouble/
Share on other sites

There is no constructor for Model_DbTable_CostTreePath(). I have a tree and I'm using a closure table to save the path of the items in my tree so along the tree comes a treepath and it's that variable that I'm trying to initialize in the tree class.

This is the beginning of the class. After that I just have its method.

Is that what you want to see?

JR

class Model_DbTable_CostTreePath extends Zend_Db_Table_Abstract 
{ 
    protected $_schema = 'test-company'; //Implementer registry et aller chercher le nom de la db pour chaque compagnie dans le registry
    protected $_name   = 'CostTreePath';
    protected $_primary = array('ancestor_id','descendant_id');
protected $_referenceMap = array(
        'Ancestor' => array(
            'columns'           => 'ancestor_id',
            'refTableClass'     => 'Model_DbTable_Tree',
            'refColumns'        => 'node_id'
        ),
        'Descendant' => array(
            'columns'           => 'descendant_id',
            'refTableClass'     => 'Model_DbTable_Tree',
            'refColumns'        => 'node_id'
        ),
    );

....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.