1

I have three criteria objects $c1, $c2, $c3

I want to return the union set of all three i.e.: ($c1 || $c2 || $c3) I have a function that expects a Criteria object, so I need to be able to return a criteria that represents the UNION of $c1, $c2 and $c3.

Does anyone know how to achieve that?

oompahloompah
  • 9,087
  • 19
  • 62
  • 90

1 Answers1

3

You can do that with criterions:

<?php

$c = new Criteria();
$cton1 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, "Leo");
$cton2 = $c->getNewCriterion(AuthorPeer::LAST_NAME,  array("Tolstoy", "Dostoevsky", "Bakhtin"), Criteria::IN);

// combine them
$cton1->addOr($cton2);

// add to Criteria
$c->add($cton1);
Maerlyn
  • 33,687
  • 18
  • 94
  • 85