Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

PHQL how to get the parser?

Hello I would Like to use PHQL parser in another project, how can I call it and use it?


Can you give more details?

Use the parser to translate the query to sql. is that possible?

edited Mar '15

Yes, when you have installed phalcon extension just create instance from this class, you could make something like this:


$di = new Phalcon\DI();

//Registrar un servicio 'db'

$di->set('db', function() {
    return new Phalcon\Db\Adapter\Pdo\Mysql(
        "host" => "localhost",
        "username" => "root",
        "password" => "secret",
        "dbname" => "invo"

// Instantiate the Query
$query = new Phalcon\Mvc\Model\Query("SELECT * FROM Cars");

// Pass the DI container

// Execute the query returning a result if any
$cars = $query->execute();

Or simply with php Phalcon\Mvc\Model\Manager() class

ok I do not want to use the PhalconORM for now, but I want to get the phql output to normal sql. I know I have to load the mapping and call out the parser, I just need to know how to use it or how it works and what structure is the map.


Ok, you can see here how was built it, new phalcon 2.0 version., look around here...

I think thats is it, thank you Julian. BTW if I manage to develop a multi connection DataMapper ORM in zephir, would it be interesting for phalcon?