Hi,
What you have should work:
$table1 = new $originTable();
This is the most basic form of reflection in PHP, and has been supported
natively since ages ago.
If it doesn't work, you should turn on error reporting and examine the
errors you get. Chances are the classes you're trying to instantiate aren't
included yet, in which case you could use
Zend_Load::loadClass($originTable).
For more examples on this, check out Zend_Db::factory().
Robin
On Thu, Apr 24, 2008 at 5:58 PM, Vincent <[EMAIL PROTECTED]> wrote:
>
>
> On 4/24/08, Denis Fohl <[EMAIL PROTECTED]> wrote:
>>
>> Hi all,
>>
>> sorry i forgot the subject in my previous post :
>>
>> i'm trying to implement a class to manage manytomany relationships in
>> backoffice, i'd like to standardize it for reusability.
>> I would like to pass to the constructor of my class the name of the tables
>> involved (destination table, origin table, intersection table) and that it
>> instantiate correspondings Zend_Db_Table objects.
>>
>> So now is the question : how can i instantiate an object (Zend_Db_Table
>> here) with a variable classname :
>>
>> function __construct ($originTable, $destinationTable) {
>>
>> $table1 = new $originTable();
>> ...
>>
>> }
>>
>> i can't find what i want on google (tried call_user_func but that's not
>> it).
>
>
> This sounds similar to something I've been trying to do a while ago. After
> reading a *lot* about this, I found out this was not possible before PHP
> 5.3. I'm not sure exactly where I found that, but a good starting point
> would be the comments on http://nl3.php.net/get-class .
>
> Thanks.
>>
>> Denis.
>>
>>
> Best of luck,
>
> --
> Vincent