Re: Passing arguments as they are received to another function
| From: | Luigi Perroti | Date: | Sat, 12 Jul 2008 16:36:32 +0000 |
| Subject: | Re: Passing arguments as they are received to another function | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-276698@lists.php.net to get a copy of this message | ||
On Sat, Jul 12, 2008 at 6:00 PM, James Dempster wrote:
> You might want to take a look at
> http://php.net/manual/en/function.call-user-func-array.php
Thank you very much for your suggestion.
I've looked into it but I guess this doesn't work with what I'm trying to
do, although what you suggested should indeed work perfectly with my
previous example.
Here's a snippet from the code that I'm having problems with:
class MainDatabase {
private static $mainDatabase = NULL;
private static $statement = NULL;
//...
//...
//...
public static function prepare($query) {
self::$mainDatabase->beginTransaction();
self::$statement = self::$mainDatabase->prepare($query);
}
public static function bindParam() {
self::$statement->call_user_func_array(array('PDOStatement','bindParam'),func_get_args());
// Results in:
// PHP Fatal error: Call to undefined method
PDOStatement::call_user_func_array() ...
// I've also tried with
call_user_func_array('PDOStatement::fetchAll',func_get_args());
// but no luck, same error.
}
//...
//...
//...
}
I thought that a solution for the previous example would work in this
scenario too, but I guess this isn't the case.
Any further suggestions would be very welcome, thanks.