Javatpoint Logo
Javatpoint Logo

Phalcon Query Language (PHQL)

It allows user to implement query language similar to SQL query language. PHQL is implemented as a parser which connects to RDBMS. Phalcon parser uses same technology as SQLite.

PHQL consist of features which are listed below:

  • It secures the code using bound parameters.
  • It prevents injection by executing one SQL statement per call.
  • It ignores all comments which mostly used in SQL injections.
  • It only allows data manipulation statement to execute.

PHQL Life Cycle

PHQL allows developers the ability to personalize and customize accordingly. The following is the lifecycle of PHQL statement which is executed:

  • The PHQL is parsed and converted into an Intermediate Representation (IR). IR is independent of the SQL implementation by database system.
  • The IR is converted to valid SQL according to the database system.
  • PHQL statements are parsed once and cached in memory. Further executions of the same statement result in a slightly faster execution.



First we create a front-end which takes the input.

We have 2 models Mobile and Brands:

Creating PHQL Query

It is created under directory Phalcon\Mvc\Model\Query.

Executing PHQL Query

It is executed from controller or view under directory Phalcon\Mvc\Model\Manager.


Phalcon PHQL 1

Result Types

Result type is of two types Simple and Complex depending upon the type of column we query.

If we retrieve single object then the object return is Simple Result (Phalcon\Mvc\Model\Resultset\Simple).

If we access both complete objects and scalars at once then return Complex Result (Phalcon\Mvc\Model\Resultset\Complex).

Next TopicPhalcon Models

Youtube For Videos Join Our Youtube Channel: Join Now


  • Send your Feedback to

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA