We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

PHQL - Multiple BetweenWhere clauses

Hello. In the API help ( https://docs.phalcon.io/en/latest/api/Phalcon_Mvc_Model_Query_Builder.html ) i can see that the query builder has the functions where , andWhere , orWhere . The first add the "first" where to the query. The second add a clause "and where" and the third add a clause "or where".

So far, so good.

But looking at the "between where", i can only find betweenWhere and notBetweenWhere . So, my question is: Is there no andBetweenWhere or orBetweenWhere and to execute such query i would have to do something like andWhere("column BETWEEN :min: AND :max:") ?

Thank you all very much



11.2k
edited Aug '14

Well, it seems i don't have any other option (yer). I am using ->andWhere("model.column BETWEEN :minvalue: AND :maxvalue:")



98.9k

You can use betweenWhere several times to add more than one between to the query



11.2k

Great. But how do i add the and and or because sometimes i might want to find results whose column1 is between two values AND column2 between two values and some other times i might want to find results where column1 is between two values OR between two other values.

If i use betweenWhere several times would it be an implicit andBetweenWhere ?