0

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?

0

1 Answer 1

3

try

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

Sign up to request clarification or add additional context in comments.

4 Comments

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.
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.
@Knarf: Are you removing the quotes that were present in your original post?
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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.