本文整理汇总了PHP中Propel\Runtime\ActiveQuery\Criteria::addOr方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::addOr方法的具体用法?PHP Criteria::addOr怎么用?PHP Criteria::addOr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\ActiveQuery\Criteria
的用法示例。
在下文中一共展示了Criteria::addOr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddOrEmptyCriteria
public function testAddOrEmptyCriteria()
{
$table1 = "myTable1";
$column1 = "myColumn1";
$value1 = "myValue1";
$key1 = "{$table1}.{$column1}";
$this->c->addOr($key1, $value1, Criteria::EQUAL);
$expect = "SELECT FROM myTable1 WHERE myTable1.myColumn1=:p1";
$params = array();
$result = $this->c->createSelectSql($params);
$expect_params = array(array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'));
$this->assertEquals($expect, $result, 'addOr() called on an empty Criteria adds a criterion to the criteria');
$this->assertEquals($expect_params, $params, 'addOr() called on an empty Criteria adds a criterion to the criteria');
}
示例2: testCombineCriterionOrLessSimple
public function testCombineCriterionOrLessSimple()
{
$this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL);
$this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL);
$this->c->add("INVOICE.COST3", "8000", Criteria::GREATER_EQUAL);
$this->c->combine(['cond1', 'cond2'], Criteria::LOGICAL_OR);
$this->c->addOr("INVOICE.COST4", "9000", Criteria::LESS_EQUAL);
$expect = $this->getSql("SELECT FROM INVOICE WHERE INVOICE.COST3>=:p1 AND ((INVOICE.COST1>=:p2 OR INVOICE.COST2<=:p3) OR INVOICE.COST4<=:p4)");
$expect_params = [['table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'], ['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'], ['table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000']];
$params = [];
$result = $this->c->createSelectSql($params);
$this->assertEquals($expect, $result);
$this->assertEquals($expect_params, $params);
}
示例3: doDelete
/**
* Performs a DELETE on the database, given a DiaporamaVersion or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or DiaporamaVersion object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(DiaporamaVersionTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \Diaporamas\Model\DiaporamaVersion) {
// it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else {
// it's a primary key, or an array of pks
$criteria = new Criteria(DiaporamaVersionTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(DiaporamaVersionTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(DiaporamaVersionTableMap::VERSION, $value[1]));
$criteria->addOr($criterion);
}
}
$query = DiaporamaVersionQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
DiaporamaVersionTableMap::clearInstancePool();
} elseif (!is_object($values)) {
// it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
DiaporamaVersionTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}