2
votes

i use propel for database interaction. Now i have to create a query like

SELECT data FROM values WHERE a=1 AND (vis=1 or (vis=0 AND userID=5));

I create a propel object from the table "values".

$p = new ValuesQuery()::create
   ->filterByA(1)
   ->filterByVis(1)
   ->_or()
   ->filterByVis(0)
   ->filterByUserId(5)
   ->findOne();

Propel generates the following SQL-Query which mostly makes sense:

SELECT data FROM values WHERE a=1 AND (vis=1 or vis=0) AND userID=5;

How can i fix this? Is it possible to say propel what it should put in brackets?

Thanks for all answers!

2
As per my answer to @kirilloid, I think you're looking for the combine() query operator. I've not used it, but check the docs - I think they're quite good generally.halfer

2 Answers

1
votes

Playing with next tool may not only answer your particular question, but also help you understand, how complicated conditions are built.

http://propel.jondh.me.uk/criteria/analyse

1
votes

As @halfer said, read the following documentation on how to combine several conditions: http://www.propelorm.org/reference/model-criteria.html#combining_several_conditions