How to overload methods with variable number of arguments?
<p>I have a class that holds a mysqli instance (this to avoid spreading database settings all over the source code).</p>

<p>The class DB looks like:</p>

<pre><code>class DB {
    private $mysqli;

    public function connect() {
        $this-&gt;mysqli = new mysqli("localhost", "user", "pwd", "db-name");
    }

    public function __call($method, $args) {
        return $this-&gt;mysqli-&gt;$method(extract($args));
    }
}
</code></pre>

<p>As you might see what I'm trying to do is to overload every method call executing the mysqli ones.</p>

<p>In the other php file I have:</p>

<pre><code>$unq_vstr = $this-&gt;db-&gt;query("SELECT * FROM user_log WHERE user_ip='$ip' AND user_last_visit='$now';");
if ($unq_vstr-&gt;num_rows &gt; 0) { // ERROR
    // ...
}
</code></pre>

<p>But I'm getting "Notice: Trying to get property of non-object in /home/alessandro/www/admin/index.php on line 25" corresponding to the if statement ($unq_vstr->num_rows).</p>

<p>What am I doing wrong?
I'm pretty sure it might depend on the DB class, but I can't figure out what the problem is.</p>

<p>Do you think I should use an alternative way to do it (without wrap mysqli inside my own class)?
Any suggestion is appreciated.</p>
