![]() |
|
Snippets |
|
Here is an example of obtaining a custom set of select columns using Propel Criteria, as opposed to using a custom SQL statement. The use of distinct is also demonstrated.
// Set up empty select $c = new Criteria(); $c->clearSelectColumns(); // Read distinct(owningdepot) from the load table... $c->addSelectColumn(TmsLoadPeer::OWNINGDEPOT); $c->addGroupByColumn(TmsLoadPeer::OWNINGDEPOT); $c->setDistinct(); // ...which are IN the provided list $c->add(TmsLoadPeer::LOAD_ID, $loadIds, Criteria::IN); $depots = TmsLoadPeer::doSelectRS($c); // Then return an array of depots $arrDep = array(); foreach ($depots as $depot) { $arrDep[] = $depot[0]; }