How can I call mysql function in PHQL ?

Hi everyone in my raw sql , I have one query like that SELECT * FROM places WHERE calculate_distance(lat,lng,10.8088715,106.6921842) <= 105.61305999756

Then I change PHQL SELECT * FROM ABC\Models\Places WHERE calculate_distance(lat,lng,10.8088715,106.6921842) <= 105.61305999756

But it can not run. How can I call funciton "calculate_distance" in my PHQL

edited 13d ago

From within your model:

$this->getDi()->getShared("db")->query("SELECT * FROM persons WHERE age > 21 AS old_enough_to_drink");

or statically:

\Phalcon\Di::getDefault()->getShared("db")->query("SELECT * FROM persons WHERE age > 21 AS old_enough_to_drink");

edited 13d ago

From within your model:

$this->getDi()->getShared("db")->query("SELECT * FROM persons WHERE age > 21 AS old_enough_to_drink");

or statically:

\Phalcon\Di::getDefault()->getShared("db")->query("SELECT * FROM persons WHERE age > 21 AS old_enough_to_drink");

Thanks ChangePlaces

But I still not understand what you mean

Now I have one function (like store procdure https://dev.mysql.com/doc/refman/5.7/en/create-procedure.html) .It has name "caculate_distance) . I want to use it built in my PHQL and I don't know how to call it.

SELECT * FROM ABC\Models\Places WHERE calculate_distance(lat,lng,10.8088715,106.6921842) <= 105.61305999756