本文整理汇总了PHP中Propel\Runtime\ActiveQuery\Criteria::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::add方法的具体用法?PHP Criteria::add怎么用?PHP Criteria::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\ActiveQuery\Criteria
的用法示例。
在下文中一共展示了Criteria::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDoInsert
public function testDoInsert()
{
try {
$c = new Criteria();
$c->setPrimaryTableName(BookTableMap::TABLE_NAME);
$c->add(BookTableMap::AUTHOR_ID, 'lkhlkhj');
$c->doInsert(Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME));
$this->fail('Missing expected exception on BAD SQL');
} catch (PropelException $e) {
$this->assertContains('[INSERT INTO `book` (`AUTHOR_ID`) VALUES (:p1)]', $e->getMessage(), 'SQL query is written in the exception message');
}
}
示例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: testDoInsert
public function testDoInsert()
{
$con = Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME);
try {
$c = new Criteria();
$c->setPrimaryTableName(BookTableMap::TABLE_NAME);
$c->add(BookTableMap::AUTHOR_ID, 'lkhlkhj');
$db = Propel::getServiceContainer()->getAdapter($c->getDbName());
$c->doInsert($con);
$this->fail('Missing expected exception on BAD SQL');
} catch (PropelException $e) {
if ($db->isGetIdBeforeInsert()) {
$this->assertContains($this->getSql('[INSERT INTO book (AUTHOR_ID,ID) VALUES (:p1,:p2)]'), $e->getMessage(), 'SQL query is written in the exception message');
} else {
$this->assertContains($this->getSql('[INSERT INTO `book` (`AUTHOR_ID`) VALUES (:p1)]'), $e->getMessage(), 'SQL query is written in the exception message');
}
}
}
示例4: testDoSelectOrderByRank
public function testDoSelectOrderByRank()
{
$c = new Criteria();
$c->add(SortableTable12TableMap::SCOPE_COL, 1);
$objects = SortableTable12Query::doSelectOrderByRank($c)->getArrayCopy();
$oldRank = 0;
while ($object = array_shift($objects)) {
$this->assertTrue($object->getRank() > $oldRank);
$oldRank = $object->getRank();
}
$c = new Criteria();
$c->add(SortableTable12TableMap::SCOPE_COL, 1);
$objects = SortableTable12Query::doSelectOrderByRank($c, Criteria::DESC)->getArrayCopy();
$oldRank = 10;
while ($object = array_shift($objects)) {
$this->assertTrue($object->getRank() < $oldRank);
$oldRank = $object->getRank();
}
}
示例5: doDelete
/**
* Performs a DELETE on the database, given a ModuleImage or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ModuleImage 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(ModuleImageTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \Thelia\Model\ModuleImage) {
// 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(ModuleImageTableMap::DATABASE_NAME);
$criteria->add(ModuleImageTableMap::ID, (array) $values, Criteria::IN);
}
$query = ModuleImageQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
ModuleImageTableMap::clearInstancePool();
} elseif (!is_object($values)) {
// it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
ModuleImageTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
示例6: buildCriteria
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(JaCategoriasTableMap::DATABASE_NAME);
if ($this->isColumnModified(JaCategoriasTableMap::COL_ID)) {
$criteria->add(JaCategoriasTableMap::COL_ID, $this->id);
}
if ($this->isColumnModified(JaCategoriasTableMap::COL_TITULO)) {
$criteria->add(JaCategoriasTableMap::COL_TITULO, $this->titulo);
}
if ($this->isColumnModified(JaCategoriasTableMap::COL_SLUG)) {
$criteria->add(JaCategoriasTableMap::COL_SLUG, $this->slug);
}
return $criteria;
}
示例7: buildCriteria
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(ApplicationTableMap::DATABASE_NAME);
if ($this->isColumnModified(ApplicationTableMap::COL_ID)) {
$criteria->add(ApplicationTableMap::COL_ID, $this->id);
}
if ($this->isColumnModified(ApplicationTableMap::COL_STUDENT_ID)) {
$criteria->add(ApplicationTableMap::COL_STUDENT_ID, $this->student_id);
}
if ($this->isColumnModified(ApplicationTableMap::COL_SUBJECT_ID)) {
$criteria->add(ApplicationTableMap::COL_SUBJECT_ID, $this->subject_id);
}
if ($this->isColumnModified(ApplicationTableMap::COL_PERIOD_ID)) {
$criteria->add(ApplicationTableMap::COL_PERIOD_ID, $this->period_id);
}
if ($this->isColumnModified(ApplicationTableMap::COL_SCHOOL_YEAR_ID)) {
$criteria->add(ApplicationTableMap::COL_SCHOOL_YEAR_ID, $this->school_year_id);
}
if ($this->isColumnModified(ApplicationTableMap::COL_APPLICATION_DATE)) {
$criteria->add(ApplicationTableMap::COL_APPLICATION_DATE, $this->application_date);
}
if ($this->isColumnModified(ApplicationTableMap::COL_EXAM_DATE)) {
$criteria->add(ApplicationTableMap::COL_EXAM_DATE, $this->exam_date);
}
if ($this->isColumnModified(ApplicationTableMap::COL_EXAM_TIME)) {
$criteria->add(ApplicationTableMap::COL_EXAM_TIME, $this->exam_time);
}
if ($this->isColumnModified(ApplicationTableMap::COL_EXAM_SCORE)) {
$criteria->add(ApplicationTableMap::COL_EXAM_SCORE, $this->exam_score);
}
if ($this->isColumnModified(ApplicationTableMap::COL_CREATED_AT)) {
$criteria->add(ApplicationTableMap::COL_CREATED_AT, $this->created_at);
}
if ($this->isColumnModified(ApplicationTableMap::COL_UPDATED_AT)) {
$criteria->add(ApplicationTableMap::COL_UPDATED_AT, $this->updated_at);
}
return $criteria;
}
示例8: buildCriteria
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(WishlistProductTableMap::DATABASE_NAME);
if ($this->isColumnModified(WishlistProductTableMap::COL_WISHLIST_PRODUCT_ID)) {
$criteria->add(WishlistProductTableMap::COL_WISHLIST_PRODUCT_ID, $this->wishlist_product_id);
}
if ($this->isColumnModified(WishlistProductTableMap::COL_WISHLIST_ID)) {
$criteria->add(WishlistProductTableMap::COL_WISHLIST_ID, $this->wishlist_id);
}
if ($this->isColumnModified(WishlistProductTableMap::COL_PRODUCT_ID)) {
$criteria->add(WishlistProductTableMap::COL_PRODUCT_ID, $this->product_id);
}
if ($this->isColumnModified(WishlistProductTableMap::COL_WISHLIST_PRODUCT_COMMENT)) {
$criteria->add(WishlistProductTableMap::COL_WISHLIST_PRODUCT_COMMENT, $this->wishlist_product_comment);
}
if ($this->isColumnModified(WishlistProductTableMap::COL_CREATED_AT)) {
$criteria->add(WishlistProductTableMap::COL_CREATED_AT, $this->created_at);
}
if ($this->isColumnModified(WishlistProductTableMap::COL_UPDATED_AT)) {
$criteria->add(WishlistProductTableMap::COL_UPDATED_AT, $this->updated_at);
}
return $criteria;
}
示例9: buildCriteria
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(EntityTypeTableMap::DATABASE_NAME);
if ($this->isColumnModified(EntityTypeTableMap::COL_ID)) {
$criteria->add(EntityTypeTableMap::COL_ID, $this->id);
}
if ($this->isColumnModified(EntityTypeTableMap::COL_NAME)) {
$criteria->add(EntityTypeTableMap::COL_NAME, $this->name);
}
return $criteria;
}
示例10: buildCriteria
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(SessionTableMap::DATABASE_NAME);
if ($this->isColumnModified(SessionTableMap::COL_TOKEN)) {
$criteria->add(SessionTableMap::COL_TOKEN, $this->token);
}
if ($this->isColumnModified(SessionTableMap::COL_USER_ID)) {
$criteria->add(SessionTableMap::COL_USER_ID, $this->user_id);
}
if ($this->isColumnModified(SessionTableMap::COL_IP)) {
$criteria->add(SessionTableMap::COL_IP, $this->ip);
}
if ($this->isColumnModified(SessionTableMap::COL_USER_AGENT)) {
$criteria->add(SessionTableMap::COL_USER_AGENT, $this->user_agent);
}
if ($this->isColumnModified(SessionTableMap::COL_BROWSER)) {
$criteria->add(SessionTableMap::COL_BROWSER, $this->browser);
}
if ($this->isColumnModified(SessionTableMap::COL_DEVICE)) {
$criteria->add(SessionTableMap::COL_DEVICE, $this->device);
}
if ($this->isColumnModified(SessionTableMap::COL_OS)) {
$criteria->add(SessionTableMap::COL_OS, $this->os);
}
if ($this->isColumnModified(SessionTableMap::COL_LOCATION)) {
$criteria->add(SessionTableMap::COL_LOCATION, $this->location);
}
if ($this->isColumnModified(SessionTableMap::COL_CREATED_AT)) {
$criteria->add(SessionTableMap::COL_CREATED_AT, $this->created_at);
}
if ($this->isColumnModified(SessionTableMap::COL_UPDATED_AT)) {
$criteria->add(SessionTableMap::COL_UPDATED_AT, $this->updated_at);
}
return $criteria;
}
示例11: buildCriteria
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(CommentTableMap::DATABASE_NAME);
if ($this->isColumnModified(CommentTableMap::COL_ID)) {
$criteria->add(CommentTableMap::COL_ID, $this->id);
}
if ($this->isColumnModified(CommentTableMap::COL_USER_ID)) {
$criteria->add(CommentTableMap::COL_USER_ID, $this->user_id);
}
if ($this->isColumnModified(CommentTableMap::COL_NOTE_ID)) {
$criteria->add(CommentTableMap::COL_NOTE_ID, $this->note_id);
}
if ($this->isColumnModified(CommentTableMap::COL_TEXT)) {
$criteria->add(CommentTableMap::COL_TEXT, $this->text);
}
if ($this->isColumnModified(CommentTableMap::COL_CREATED_AT)) {
$criteria->add(CommentTableMap::COL_CREATED_AT, $this->created_at);
}
if ($this->isColumnModified(CommentTableMap::COL_UPDATED_AT)) {
$criteria->add(CommentTableMap::COL_UPDATED_AT, $this->updated_at);
}
return $criteria;
}
示例12: buildCriteria
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(RigAttributeValueTableMap::DATABASE_NAME);
if ($this->isColumnModified(RigAttributeValueTableMap::COL_ID)) {
$criteria->add(RigAttributeValueTableMap::COL_ID, $this->id);
}
if ($this->isColumnModified(RigAttributeValueTableMap::COL_RIG_ID)) {
$criteria->add(RigAttributeValueTableMap::COL_RIG_ID, $this->rig_id);
}
if ($this->isColumnModified(RigAttributeValueTableMap::COL_RIG_ATTRIBUTE_ID)) {
$criteria->add(RigAttributeValueTableMap::COL_RIG_ATTRIBUTE_ID, $this->rig_attribute_id);
}
if ($this->isColumnModified(RigAttributeValueTableMap::COL_VALUE)) {
$criteria->add(RigAttributeValueTableMap::COL_VALUE, $this->value);
}
return $criteria;
}
示例13: buildCriteria
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(UserTableMap::DATABASE_NAME);
if ($this->isColumnModified(UserTableMap::COL_ID)) {
$criteria->add(UserTableMap::COL_ID, $this->id);
}
if ($this->isColumnModified(UserTableMap::COL_NAME)) {
$criteria->add(UserTableMap::COL_NAME, $this->name);
}
if ($this->isColumnModified(UserTableMap::COL_EMAIL)) {
$criteria->add(UserTableMap::COL_EMAIL, $this->email);
}
if ($this->isColumnModified(UserTableMap::COL_PASSWORD)) {
$criteria->add(UserTableMap::COL_PASSWORD, $this->password);
}
if ($this->isColumnModified(UserTableMap::COL_REMEMBER)) {
$criteria->add(UserTableMap::COL_REMEMBER, $this->remember);
}
if ($this->isColumnModified(UserTableMap::COL_ACCOUNT_TYPE)) {
$criteria->add(UserTableMap::COL_ACCOUNT_TYPE, $this->account_type);
}
if ($this->isColumnModified(UserTableMap::COL_CREATED_AT)) {
$criteria->add(UserTableMap::COL_CREATED_AT, $this->created_at);
}
if ($this->isColumnModified(UserTableMap::COL_UPDATED_AT)) {
$criteria->add(UserTableMap::COL_UPDATED_AT, $this->updated_at);
}
return $criteria;
}
示例14: buildCriteria
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(WpUsermetaTableMap::DATABASE_NAME);
if ($this->isColumnModified(WpUsermetaTableMap::COL_UMETA_ID)) {
$criteria->add(WpUsermetaTableMap::COL_UMETA_ID, $this->umeta_id);
}
if ($this->isColumnModified(WpUsermetaTableMap::COL_USER_ID)) {
$criteria->add(WpUsermetaTableMap::COL_USER_ID, $this->user_id);
}
if ($this->isColumnModified(WpUsermetaTableMap::COL_META_KEY)) {
$criteria->add(WpUsermetaTableMap::COL_META_KEY, $this->meta_key);
}
if ($this->isColumnModified(WpUsermetaTableMap::COL_META_VALUE)) {
$criteria->add(WpUsermetaTableMap::COL_META_VALUE, $this->meta_value);
}
return $criteria;
}
示例15: buildPkeyCriteria
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
public function buildPkeyCriteria()
{
$criteria = new Criteria(MenuItemVersionTableMap::DATABASE_NAME);
$criteria->add(MenuItemVersionTableMap::ID, $this->id);
$criteria->add(MenuItemVersionTableMap::MENU_ID, $this->menu_id);
$criteria->add(MenuItemVersionTableMap::VERSION, $this->version);
return $criteria;
}