Connect to mysql using Zaphir

500 Views Asked by At

How can I connect to my sql using Zephir, also I'm using php, I tried the link but failed.

this is how I use the code.

public function setConnection(connection) -> void
{
    let this->_connection = connection;
}

let myDb = db->setConnection(connection);
myDb->execute("SELECT * FROM robots");

it gives only a vauge idea and throws exception

thanks and regards.

1

There are 1 best solutions below

3
On

You assign the return value of setConnection to myDb. (which gets set to null, since setConnection does not return anything) Then you call myDb->execute which is NULL->execute().

So you call a function of null, insteadof on an object.