oompahloompah
oompahloompah

Reputation: 9343

Propel ORM UNION query

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?

Upvotes: 1

Views: 2147

Answers (1)

Maerlyn
Maerlyn

Reputation: 34105

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);

Upvotes: 3

Related Questions