在学习Phalcon的过程中遇到了这样一句SQL,希望能够用PHQL去组成一个query进行查询,可以因为水平不够,所以不知道怎么写,求大神帮忙指点,感激不尽!
while i was learning Phalcon Framework, I have this sql ,but i can not translate it to PHQL to build a queryBuiler to make it easier for pagination, hope for your help .Thx a lot.
SELECT
`name`,`level`,`subject`,`count`
FROM teacher
WHERE
(`level`=1)and(
(`count`=0) OR
((`count` IN (1, 4, 5) AND (`subject` LIKE '%physics%' OR `subject` LIKE '%chemistry%' OR `subject` LIKE '%maths%')) OR
(`count` = 2 AND (`subject` = 'physics,chemistry' OR `subject` = 'physics,maths' OR `subject` = 'chemistry,maths')) OR
(`count` = 3 AND `subject` = 'physics,chemistry,maths'))
)
order by school_name,level,`subject` desc limit 3,15