mysql - Complex WHERE clauses using the PHP Doctrine ORM -


I am using PHP principle ORM to build my own questions. However, I could not understand how to write the following WHERE clause using DQL (Dictine Choir Language):

  WHERE name = 'ABC' AND (category1 = 'X' OR category2 = ' X 'or Category 3 =' X ') and Price & gt; 10  

How can I specify where the brackets go?

What do I currently have in my PHP code:

  - & gt; Where ('name =?', 'ABC') - & gt; And where ('Category1 =' ',' X ') -> or where (' class2 =? ',' X ') -> or where (' class3 =? ',' X ') - gt; And where ('price & gt ;?', 10)  

but it produces something like

  WHERE name = 'ABC' and Category 1 = 'X' or Category 2 = 'X' or Category 3 = 'X' and value & gt; 10  

Due to the order of operation, the desired result does not return.

Besides, "where", "and" where ", and" plus anywhere "methods?

UPDATE OK, it looks like you Using DQL can not make complex queries, so I'm trying to manually write SQL and where () method to add it though, where am I using this theory, my inclusion The parentheses take out:

  $ q-> and where ("($ 1 IN $ subcategory_in_clause or $ 2 IN $ subcategory_in_clause OR sh Category 3 IN $ subcategory_in_clause);  

From my experience, every complex code > Where the function is grouped within parentheses (I am using the principle 1.2.1).

  $ q-> where ('name =?', 'ABC') -> and where ('category1 =? Or category2 =? Or class 3 =?', Array ('x', 'x', 'x')) -> and where 'Pricing'  

produces the following SQL:

  WHERE name = 'ABC' and (Category1 = 'X' 'Or Category 2 =' Bus or Category 3 = 'X') and the value & lt; 10  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -