Doctrine Query Language (DQL) is an "object query language", which means you 
are not querying tables and columns, but php objects (Entities) and properties. 
Think about it as a query language for your object model, not for your 
relational schema.

NativeQuery is a tool to perform raw SQL queries. It's _not_ limited to MySQL, 
it works with any vendor that Doctrine support.

But the actual SQL queries _you_ write can be limited to the vendor you wrote 
the queries for. Not all vendors support the exact same SQL syntax. So if you 
write SQL queries for MySQL, and switch to sqlite later on, you might encounter 
problems.

Usually you only use NativeQuery when the query you want to perform cannot be 
written in DQL. A common example is if you need to use vendor-specific 
statements.

My advise on when to use what: Try DQL first. If your missing support for 
something, try to write a custom function [1]. If that fails, use NativeQuery.


[1]: 
http://docs.doctrine-project.org/en/latest/reference/dql-doctrine-query-language.html#adding-your-own-functions-to-the-dql-language

-- 
Jasper N. Brouwer
(@jaspernbrouwer)


On 12 Feb 2014, at 13:41, Nima Sadjadi <[email protected]> wrote:

> If I understood correctly the diff. of DQL with native thing is that DQL is 
> platform-independent so ny user can change pdo_mysql in config.php to use 
> SQLite instead, if interested but native thing works only with MySQL. So if i 
> want to allow my users to switch from mysql to sqlite or whatever else to use 
> my product i should avoid native thing. Got it correctly? Please advice if I 
> am correct understanding this?

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to