Combine AND & OR operants in elgg_list_entities

Hi everyone,

I have question about how to use elgg_list_entities combining AND & OR operants, if it possible.

Here is my code.

$option = array(
     'types' => 'object',
     'subtypes' => 'MYNEWENTITY',
     'pagination' => true,
     'metadata_name_value_pairs' => array(
          array('name' => 'param1', 'value' => $param1, 'operand' => '='),
          array('name' => 'param2', 'value' => $param2, 'operand' => '='),
          array('name' => 'param3', 'value' => $param3, 'operand' => '='),
          array('name' => 'param4', 'value' => $param4, 'operand' => '='),
     ),
     'metadata_name_value_pairs_operator' => 'AND',
);

$objects = elgg_list_entities($option);

The above code will produce a query with the following clause.

"WHERE param1='$param1' AND param2='$param2' AND param3='$param3' AND param4='$param4' "

What  if I need a where clause combining AND & OR operants something like:

"WHERE param1='$param1' AND param2='$param2' AND (param3='$param3' OR param4='$param4' )"

I don't want to make 2 queries and compine results.

Is there any other solution? 

Regards,

 

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking