tags:

views:

43

answers:

1

I have a class with this in

self::$DB = new PDO("mysql:dbname=$dbname;host:=127.0.0.1" , 'root' , '');

and then this

public static function __callStatic($name, $arguments)
{
 return call_user_func_array(array('self::$DB', $name), $arguments);
}

How does I make it right/work?

+2  A: 

try

return forward_static_call_array(array(self::$DB, $name), $arguments);

RobertPitt
In that case, var_dump(self::$DB), 'cause it ain't no PDO instance in __callStatic(). The problem is probably higher up the chain / in the order of arguments.
Wrikken
Make sure that the first line of code you quote (where you instantiate a new PDO object) is executed before calling a static method on that class. Perhaps the best thing to do is instantiate it right there in the __callStatic method.
Lucas Oman
@Knarf: Are you removing the quotes that were present in your original post?
webbiedave
@Knarf: Huh? --
webbiedave
its talking about hte first item within the first array so in other words its slef::$DB .. Try return forward_static_call_array(array(get_class(self::$DB),$name),$arguments);
RobertPitt