Please note, this is a STATIC archive of website www.javatpoint.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
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.

Implementation

Front-end

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.

Output:

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

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA