本文整理汇总了PHP中Criteria::addOr方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::addOr方法的具体用法?PHP Criteria::addOr怎么用?PHP Criteria::addOr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::addOr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveByUri
/**
* description
*
* @return Schema
*
* @param string $uri
*
*/
public static function retrieveByUri($uri)
{
$criteria = new Criteria();
$criteria->add(self::URI, $uri);
$criteria->addOr(self::URI, $uri . "#");
$criteria->addOr(self::URI, $uri . "/");
return self::doSelectOne($criteria);
}
示例2: createSearchCriteria
function createSearchCriteria($phrase, $where = false)
{
$c = new Criteria();
if ($phrase) {
$rawPhrase = addslashes($phrase);
$phrase = strtr($phrase, '+-><()~*"', ' ');
$words = preg_split("#\\s+#", $phrase);
$booleanOperator = Config::get("searchEngineWordDefaultOperator") == "AND" ? "+" : "";
$phrase = $booleanOperator . implode(" " . $booleanOperator, $words);
$phrase = addslashes($phrase);
$searchEngineSearchInFields = explode("|", Config::get("searchEngineSearchIn"));
$fullTextSearchFields = array("siteTitle", "description");
$searchInFields = "";
foreach ($fullTextSearchFields as $field) {
if (in_array($field, $searchEngineSearchInFields)) {
if ($searchInFields) {
$searchInFields .= ", ";
}
$searchInFields .= $field;
}
}
if ($searchInFields) {
$cc = new Criteria();
$cc->add("MATCH ({$searchInFields}) AGAINST ('{$phrase}' IN BOOLEAN MODE)");
$searchEngineLikeMethodEnabled = Config::get('searchEngineLikeMethodEnabled');
$searchEngineLikeMethodWordMinLength = Config::get('searchEngineLikeMethodWordMinLength');
$searchEngineLikeMethodWordMaxLength = Config::get('searchEngineLikeMethodWordMaxLength');
if ($searchEngineLikeMethodEnabled) {
$conjunction = Config::get("searchEngineWordDefaultOperator") == 'AND' ? 'AND' : 'OR';
foreach ($words as $word) {
$strlen = strlen($word);
if ($strlen <= $searchEngineLikeMethodWordMaxLength && $strlen >= $searchEngineLikeMethodWordMinLength) {
foreach ($fullTextSearchFields as $field) {
if (in_array($field, $searchEngineSearchInFields)) {
$cc->add($field, "%" . str_replace(array("%", "?"), "", $word) . "%", "LIKE", $conjunction);
}
}
}
}
}
if (in_array("url", $searchEngineSearchInFields)) {
$cc->addOr("LOCATE( '{$rawPhrase}', url ) > 0 ");
}
$c->add($cc);
}
}
if ($where) {
$rawWhere = addslashes($where);
$c2 = new Criteria();
$c2->addOr("LOCATE( '{$rawWhere}', address ) > 0 ");
$c2->addOr("LOCATE( '{$rawWhere}', city ) > 0 ");
$c2->addOr("LOCATE( '{$rawWhere}', zipCode ) > 0 ");
$c->add($c2);
}
return $c;
}
示例3: retrieveByUri
/**
* description
*
* @return return_type
* @param var_type $var
*/
public static function retrieveByUri($uri)
{
$con = Propel::getConnection(self::DATABASE_NAME);
$criteria = new Criteria(VocabularyPeer::DATABASE_NAME);
$criteria->add(self::URI, $uri);
$criteria->addOr(self::URI, $uri . "#");
$criteria->addOr(self::URI, $uri . "/");
$v = VocabularyPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
示例4: del
function del(Criteria $c)
{
$condition = $c->getCondition("categoryId");
$categoryId = $condition['value'];
$childCategoriesIds = array_map(create_function('$category', 'return $category[\'categoryId\'];'), $this->getChilds($categoryId, true));
$parentIds = array_map(create_function('$category', 'return $category[\'categoryId\'];'), $this->getParents($categoryId));
//creating list of items to delete
$c = new Criteria();
$c->add("categoryId", $childCategoriesIds, "IN");
$itemIds = $this->site->getArray($c, "siteId", false);
//delete all categories and subcategoeis
$c = new Criteria();
$c->add("categoryId", $childCategoriesIds, "IN");
parent::del($c);
$this->extraFieldCategory->del($c);
$c = new Criteria();
$c->add("childId", $childCategoriesIds, "IN");
$c->addOr("parentId", $childCategoriesIds, "IN");
$this->categoryParent->del($c);
//deleting items
foreach ($itemIds as $itemId) {
$c = new Criteria();
$c->add("siteId", $itemId);
$this->site->del($c, false);
}
$this->updateValidatedSitesCount($parentIds);
Cacher::getInstance()->clean("tag", array("category", "site"));
}
示例5: getEmailAccounts
public function getEmailAccounts()
{
$criteria = new Criteria();
$criteria->add(self::STATUS, 'activated');
$criteria->addOr(self::STATUS, 'disactivated');
return self::doSelect($criteria);
}
示例6: setAdOnPage
function setAdOnPage($data)
{
$c = new Criteria();
$c->add("page", $data['page']);
$c->add("place", $data['place']);
if ($data['adCriterionId'] == 0 && !in_array($data['place'], array("general", "predefine"))) {
$this->del($c);
} else {
$ad = $this->ad->find($c);
if ($ad) {
$ad->adCriterionId = $data['adCriterionId'];
$ad->save();
} else {
$ad = new AdRecord();
$ad->fromArray($data);
$ad->save();
}
}
//if globall switch was set delete category specified settings
if ($data['place'] == "general" && preg_match("#^predefine(Category|Site|Keyword|Letter|Tag)#", $data['page'], $match)) {
$pagePrefix = strtolower($match[1]);
$c = new Criteria();
$c->add("page LIKE '{$pagePrefix}%'");
$c2 = new Criteria();
$c2->add("place", "general");
$c2->addOr("place", "predefine");
$c->add($c2);
$this->del($c);
}
}
示例7: getCriterioNoBorrado
public static function getCriterioNoBorrado($atributo)
{
$c = new Criteria();
$c->add($atributo, null, Criteria::ISNULL);
$c->addOr($atributo, '0000-00-00 00:00:00', Criteria::EQUAL);
return $c;
}
示例8: calculate
public function calculate($user)
{
$c = new Criteria();
$c->add('user_id', $user->getUserId());
$c->addOr('target_user_id', $user->getUserId());
$count = DB_ContactPeer::instance()->selectCount($c);
return $count;
}
示例9: executeAbout
public function executeAbout(sfWebRequest $request)
{
$c = new Criteria();
//1,2,4,5,6,7
$c->add(sfGuardUserPeer::ID, 1);
$c->addOr(sfGuardUserPeer::ID, 2);
$c->addOr(sfGuardUserPeer::ID, 4);
$c->addOr(sfGuardUserPeer::ID, 5);
$c->addOr(sfGuardUserPeer::ID, 22);
$c->addOr(sfGuardUserPeer::ID, 7);
$c->addOr(sfGuardUserPeer::ID, 31);
$c->addOr(sfGuardUserPeer::ID, 180);
$c->addOr(sfGuardUserPeer::ID, 9);
$c->addOr(sfGuardUserPeer::ID, 738);
$c->addOr(sfGuardUserPeer::ID, 27);
$c->addOr(sfGuardUserPeer::ID, 447);
$c->addAscendingOrderByColumn(sfGuardUserPeer::ID);
$users = sfGuardUserPeer::doSelect($c);
$this->users = array();
foreach ($users as $user) {
$this->users[$user->getid()] = $user;
}
$this->title = sfContext::getInstance()->getI18N()->__('Sobre Voota - Quiénes somos', array());
$this->response->setTitle($this->title);
}
示例10: getDueDate
public function getDueDate()
{
$c = new Criteria();
$c->add(CirHistoryPeer::COL_ITEM_ID, $this->getId());
$c->add(CirHistoryPeer::RETURN_DATE, null, Criteria::EQUAL);
$c->addOr(CirHistoryPeer::RETURN_DATE, '', Criteria::EQUAL);
$ch = CirHistoryPeer::doSelectOne($c);
return $ch->getDueDate('d-m-Y H:i:s');
}
示例11: countValidCourseSubjectStudentMarks
public function countValidCourseSubjectStudentMarks()
{
$c = new Criteria();
$criterion = $c->getNewCriterion(CourseSubjectStudentMarkPeer::IS_FREE, true, Criteria::EQUAL);
$criterion->addOr($c->getNewCriterion(CourseSubjectStudentMarkPeer::IS_CLOSED, true, Criteria::EQUAL));
$criterion->addOr($c->getNewCriterion(CourseSubjectStudentMarkPeer::MARK, null, Criteria::ISNOTNULL));
$c->addOr($criterion);
return $this->countCourseSubjectStudentMarks($c);
}
示例12: getTestHijos
public static function getTestHijos($padres)
{
$criteria = new Criteria();
foreach ($padres as $padre) {
$criteria->addOr(TestsPeer::TESTS_ID, $padre->getTests()->getId(), Criteria::IN);
}
$criteria->addAscendingOrderByColumn(self::TITULO);
return self::doSelectJoinAll($criteria);
}
示例13: getUnusedPaidOne
public function getUnusedPaidOne($c)
{
$c2 = new Criteria();
$c2->add("status", "paid");
$c2->addOr("status", "pending");
$c->add($c2);
$c->add("used", 0);
$c->addOrder("paymentId");
return $this->find($c);
}
示例14: getFilesByExternalKeys
public static function getFilesByExternalKeys($filedescs)
{
$fileCriteria = new Criteria();
sfContext::getInstance()->getLogger()->info('foobar: build criteria start');
foreach ($filedescs as $key => $file) {
$tracknr = $file->getTracknr();
$fileCriteria->addOr($fileCriteria->getNewCriterion(FilePeer::EXTERNAL_KEY, $tracknr));
}
sfContext::getInstance()->getLogger()->info('foobar: build criteria done');
$files = FilePeer::doSelect($fileCriteria);
sfContext::getInstance()->getLogger()->info('foobar: query finished');
return $files;
}
示例15: 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 = BasePeer::createSelectSql($this->c, $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');
}