Post

1 follower Follow
0
Avatar

Composite Query(ORing two Ands) in Where in PHP

Hi,

 

I am trying to create a composite expression in WHERE clause in PHP. Below is code snippet for Anding multiple condition:

$AndCondition = array(

"Conditions" => array( new SoapVar ( $condition1,SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries" ),

new SoapVar ( $condition2,SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries" ),

new SoapVar ( $condition3,SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries" ),

new SoapVar ( $condition4,SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries" )));

 

And we add below param:

"Where" =>new SoapVar ($AndCondition, SOAP_ENC_OBJECT, "And", "http://clarizen.com/api/queries"),

"Paging" => array(

"PageNumber" => 0,

"PageSize" =>1000

) ,

We need to Or two experession like (cond1 And cond2) OR (cond3 AND cond4). Please help!

 

Thanks,

Shivani

 

Thanks,

Shivani

Shivani Gupta Answered

Please sign in to leave a comment.

1 comment

0
Avatar

Hi Shivani.

Each condition in the Conditions array can be And or Or condition itself. Schematically (this is not a PHP code, just the concept of the structure) you need to build something like this:

Condition And1 = And (condition1, condition2)

Condition And2 = And (condition3, condition4)

Condition where = OR (And1, And2)

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink