Re: Import symbol table into function' scope.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2011/6/15 Дмитрий Степанов <dmitrij@xxxxxxxxxxx>

> So I wonder if there is any way to import scope (symbol table) into the
> method DBReader::readSomething()?
>

Since you're using call_user_func_array() to call your internal methods
already (just to expose protected methods publicly?), you could add $DB as a
parameter.

    public function __call($method, $args) {
        array_unshift($args, $this->DB);
        return call_user_func_array( array( $this, $method), $args);
    }

    protected function readSomething($DB) {
        $DB->query(...);
        $DB->numRows();
        ...
    }

I would advise getting used to the $this-> everywhere. I can from Java where
that's not required but don't really mind it anymore. However, the above
would work and be automatic once you added the parameter to each method.

Peace,
David

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux