0

I have searched the web, the PHP manual and checked some reference books,
but I can find any satisfactory answer to my question.
Perhaps It my poor grasp of the constructor concept and it's proper application?

Here is the issue:
I have a an existing class constructor definition that I wish to overload.

function__construct( $table, $key, &$db )

    {

        $this->_tbl        = $table;

        $this->_tbl_key    = $key;

        $this->_db        =& $db;

    }

when it is called to extend the class, they use :

function __construct(&$db)
{
    parent::__construct('myTableName','my_id',$db);
}

This is used to pass specific variables to the database object (&$db) ???

I would like to overload this to take one more column argument, so that two "search" variables may be used, the primary key and and indexed column.

what is the correct way to do this?
Also why do they use the parent:: operator, what is theory of operation here?

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by JRM
0

You can just make another constructor taking a different number of args for overloading.

parent:: is used to call the parents constructor, which must be done before the child begins to construct. The Employee must be set up before construction of the Janitor can begin. D:)

0

You can just make another constructor taking a different number of args for overloading.

parent:: is used to call the parents constructor, which must be done before the child begins to construct. The Employee must be set up before construction of the Janitor can begin. D:)

Thanks dfor the reply.
I tried just creating a constructor, but I get "missing" argument errors. I tried by replicating the original in my new sub class and just adding the new arg and variable to the mix as were the others.
No joy!
I tried adding one arg to an "inherited" function, but that didn't work out either.

I may have mis-categorized the function as a class constructor.
It's actually a sub-class constructor, so my changes would be an
overload in the sub-class extension in a third generation, so to speak. The original constructor is just a null set

I thought that the extension should inherit from sub-class, but not down three levels?

Like I said, this is all rather mystifying to me.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.