Example #1
0
 public function testClone()
 {
     $c1 = new Criteria();
     $c1->add('tbl.COL1', 'foo', Criteria::EQUAL);
     $c2 = clone $c1;
     $c2->addAnd('tbl.COL1', 'bar', Criteria::EQUAL);
     $nbCrit = 0;
     foreach ($c1->keys() as $key) {
         foreach ($c1->getCriterion($key)->getAttachedCriterion() as $criterion) {
             $nbCrit++;
         }
     }
     $this->assertEquals(1, $nbCrit, 'cloning a Criteria clones its Criterions');
 }
Example #2
0
 /**
  * Helper method which returns the primary key contained
  * in the given Criteria object.
  *
  * @param      Criteria $criteria A Criteria.
  * @return     ColumnMap If the Criteria object contains a primary
  *          key, or null if it doesn't.
  * @throws     \Propel\Runtime\Exception\RuntimeException
  */
 private static function getPrimaryKey(Criteria $criteria)
 {
     // Assume all the keys are for the same table.
     $keys = $criteria->keys();
     $key = $keys[0];
     $table = $criteria->getTableName($key);
     $pk = null;
     if (!empty($table)) {
         $dbMap = Propel::getServiceContainer()->getDatabaseMap($criteria->getDbName());
         $pks = $dbMap->getTable($table)->getPrimaryKeys();
         if (!empty($pks)) {
             $pk = array_shift($pks);
         }
     }
     return $pk;
 }
Example #3
0
 public function __construct(Criteria $criteria)
 {
     $this->criteria = $criteria;
     $this->criteriaKeys = $criteria->keys();
     $this->criteriaSize = count($this->criteriaKeys);
 }