当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Query::whereIn方法代码示例

本文整理汇总了PHP中Doctrine_Query::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Query::whereIn方法的具体用法?PHP Doctrine_Query::whereIn怎么用?PHP Doctrine_Query::whereIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Query的用法示例。


在下文中一共展示了Doctrine_Query::whereIn方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: modifyQuery

 public function modifyQuery(Doctrine_Query $query)
 {
     if (!$this->getNode()->isRoot()) {
         $nodes = $this->getNode()->getDescendants(null, true);
         if ($nodes) {
             $sectionIds = array();
             foreach ($nodes as $node) {
                 $sectionIds[] = $node->id;
             }
             $query->whereIn('t.talk_section_id', $sectionIds);
         }
     }
 }
开发者ID:limitium,项目名称:uberlov,代码行数:13,代码来源:TalkSection.class.php

示例2: buildQuery

 function buildQuery(Doctrine_Query $query)
 {
     $query->orderBy('swBlogComment.created_at ASC');
     $query->leftJoin('swBlogComment.swBlogPost');
     if ($this->getValue('moderated') == -2) {
         $query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_NONE, swBlogComment::MODERATED_OK));
     }
     if ($this->getValue('moderated') == -1) {
         $query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_NONE));
     }
     if ($this->getValue('moderated') == -3) {
         $query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_KO, swBlogComment::MODERATED_OK));
     }
     if ($this->getValue('moderated') == 1) {
         $query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_OK));
     }
     if ($this->getValue('moderated') === 0) {
         $query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_KO));
     }
     if (is_numeric($this->getValue('post_id'))) {
         $query->addWhere('swBlogComment.post_id = ?', $this->getValue('post_id'));
     }
     return $query;
 }
开发者ID:rande,项目名称:swBlogPlugin,代码行数:24,代码来源:baseSwBlogCommentsDatagrid.class.php

示例3: linkInDb

 public function linkInDb($alias, $ids)
 {
     $identifier = array_values($this->identifier());
     $identifier = array_shift($identifier);
     $rel = $this->getTable()->getRelation($alias);
     if ($rel instanceof Doctrine_Relation_Association) {
         $modelClassName = $rel->getAssociationTable()->getComponentName();
         $localFieldName = $rel->getLocalFieldName();
         $localFieldDef = $rel->getAssociationTable()->getColumnDefinition($localFieldName);
         if ($localFieldDef['type'] == 'integer') {
             $identifier = (int) $identifier;
         }
         $foreignFieldName = $rel->getForeignFieldName();
         $foreignFieldDef = $rel->getAssociationTable()->getColumnDefinition($foreignFieldName);
         if ($foreignFieldDef['type'] == 'integer') {
             for ($i = 0, $l = count($ids); $i < $l; $i++) {
                 $ids[$i] = (int) $ids[$i];
             }
         }
         foreach ($ids as $id) {
             $record = new $modelClassName();
             $record[$localFieldName] = $identifier;
             $record[$foreignFieldName] = $id;
             $record->save();
         }
     } else {
         if ($rel instanceof Doctrine_Relation_ForeignKey) {
             $q = new Doctrine_Query();
             $q->update($rel->getTable()->getComponentName())->set($rel->getForeign(), '?', array_values($this->identifier()));
             if (count($ids) > 0) {
                 $q->whereIn($rel->getTable()->getIdentifier(), $ids);
             }
             $q->execute();
         } else {
             if ($rel instanceof Doctrine_Relation_LocalKey) {
                 $q = new Doctrine_Query();
                 $q->update($this->getTable()->getComponentName())->set($rel->getLocalFieldName(), '?', $ids);
                 if (count($ids) > 0) {
                     $q->whereIn($rel->getTable()->getIdentifier(), array_values($this->identifier()));
                 }
                 $q->execute();
             }
         }
     }
     return $this;
 }
开发者ID:hasanozgan,项目名称:kissabe,代码行数:46,代码来源:Record.php

示例4: addToQuery

 /**
  * Create the query for selecting objects, eventually along with related
  * objects
  *
  * @param   array   $params  an array of criterions for the selection
  */
 public function addToQuery(Doctrine_Query $query, $params)
 {
     if (isset($sort)) {
         $query->orderBy($sort);
     }
     if (isset($params['id'])) {
         $values = explode(',', $params['id']);
         if (count($values) == 1) {
             $query->andWhere($this->model . '.id = ?', $values[0]);
         } else {
             $query->whereIn($this->model . '.id', $values);
         }
         unset($params['id']);
     }
     foreach ($params as $name => $value) {
         $query->andWhere($this->model . '.' . $name . ' = ?', $value);
     }
     return $query;
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:25,代码来源:actions.class.php

示例5: addCondition

 /**
  * Adds a new condition to the current query
  * $filter is the value to be filtered
  * $op is the opreand to be used: =,>=, like, llike,REGEX,
  * $completeField. use the index $completField['field'] to
  * specify the field, to avoid ambiguous
  *
  * @param $filter
  * @param $op
  * @param $completeField
  * @return Bvb_Grid_Source_Doctrine
  */
 public function addCondition($filter, $op, $completeField)
 {
     $field = $completeField['field'];
     /**
      * FIX : #218
      * We need to make sure to use HAVING when there is function
      * in the select, as you cannot use these selected fields in the
      * WHERE clause, and all others will use the WHERE clause
      */
     $func = 'addWhere';
     if (strpos($field, '(') !== false) {
         $func = 'addHaving';
     }
     switch (strtolower($op)) {
         case 'sqlexp':
             $this->_query->{$func}($filter);
             break;
         case 'isnull':
             $this->_query->{$func}($field . ' IS NULL ');
             break;
         case 'isnnotull':
             $this->_query->{$func}($field . ' IS NOT NULL ');
             break;
         case 'empty':
             $this->_query->{$func}($field . " =''");
             break;
         case 'equal':
         case '=':
             $this->_query->{$func}($field . ' = ?', $filter);
             break;
         case 'regex':
             $this->_query->{$func}($field . " REGEXP ?", $filter);
             break;
         case 'rlike':
             $this->_query->{$func}($field . " LIKE ?", $filter . "%");
             break;
         case 'llike':
             $this->_query->{$func}($field . " LIKE ?", "%" . $filter);
             break;
         case '>=':
             $this->_query->{$func}($field . " >= ?", $filter);
             break;
         case '>':
             $this->_query->{$func}($field . " > ?", $filter);
             break;
         case '<>':
         case '!=':
             $this->_query->{$func}($field . " <> ?", $filter);
             break;
         case '<=':
             $this->_query->{$func}($field . " <= ?", $filter);
             break;
         case '<':
             $this->_query->{$func}($field . " < ?", $filter);
             break;
         case 'in':
             $filter = explode(',', $filter);
             $this->_query->whereIn($field, $filter);
             break;
         case '&':
         case 'and':
         case 'AND':
         case 'flag':
         case 'FLAG':
             $this->_query->{$func}($field . " & ? <> 0", $filter);
             break;
         case 'range':
             $start = substr($filter, 0, strpos($filter, '<>'));
             $end = substr($filter, strpos($filter, '<>') + 2);
             $this->_query->{$func}($field . " between ? and ?", array($start, $end));
             break;
         case '||':
             $this->_query->orWhere($field . " LIKE ?", "%" . $filter . "%");
             break;
         case 'like':
         default:
             $this->_query->{$func}($field . " LIKE ?", "%" . $filter . "%");
             break;
     }
     return $this;
 }
开发者ID:robjacoby,项目名称:xlr8u,代码行数:93,代码来源:Doctrine.php

示例6: addTagsListColumnQuery

 public function addTagsListColumnQuery(Doctrine_Query $query, $field, $values)
 {
     if (!is_array($values)) {
         $values = array($values);
     } else {
         $values = array_keys($values);
     }
     if (!count($values)) {
         return;
     }
     $ids = Doctrine::getTable('tagging')->createQuery()->select('taggable_id')->leftJoin('tagging.Tag tag')->where('taggable_model = ?', $this->getModelName())->andWhereIn('tag.name', $values)->groupBy('taggable_id')->execute(array(), Doctrine::HYDRATE_SCALAR);
     $ids = array_map(create_function('$i', 'return $i["tagging_taggable_id"];'), $ids);
     if (empty($ids)) {
         $query->where('false');
     } else {
         $query->whereIn($query->getRootAlias() . '.id', $ids);
     }
 }
开发者ID:existanze,项目名称:apostropheBlogPlugin,代码行数:18,代码来源:PluginaBlogItemFormFilter.class.php

示例7: applyDealIdFilter

 /**
  * Applies the alarming attribute to a given query retrieving products.
  *
  * @param Doctrine_Query $query - query to have alarming attribute applied.
  * @param Integer $value - alarming?
  */
 public function applyDealIdFilter($query, $value)
 {
     $rootAlias = $query->getRootAlias();
     $dm = MongoManager::getDM();
     $yas = $dm->getRepository('Documents\\YiidActivity')->findBy(array('d_id' => intval($value)));
     $user_ids = array();
     foreach ($yas as $ya) {
         $user_ids[] = $ya->getUId();
     }
     $user_ids = array_unique($user_ids);
     if (count($user_ids) == 0) {
         $user_ids[] = -1;
     }
     $query->whereIn($rootAlias . '.id', $user_ids);
     return $query;
 }
开发者ID:42medien,项目名称:spreadly,代码行数:22,代码来源:UserTable.class.php

示例8: unlink

 /**
  * unlink
  * removes links from this record to given records
  * if no ids are given, it removes all links
  *
  * @param string $alias     related component alias
  * @param array $ids        the identifiers of the related records
  * @return Doctrine_Record  this object
  */
 public function unlink($alias, $ids = array())
 {
     $ids = (array) $ids;
     $q = new Doctrine_Query();
     $rel = $this->getTable()->getRelation($alias);
     if ($rel instanceof Doctrine_Relation_Association) {
         $q->delete()->from($rel->getAssociationTable()->getComponentName())->where($rel->getLocal() . ' = ?', array_values($this->identifier()));
         if (count($ids) > 0) {
             $q->whereIn($rel->getForeign(), $ids);
         }
         $q->execute();
     } else {
         if ($rel instanceof Doctrine_Relation_ForeignKey) {
             $q->update($rel->getTable()->getComponentName())->set($rel->getForeign(), '?', array(null))->addWhere($rel->getForeign() . ' = ?', array_values($this->identifier()));
             if (count($ids) > 0) {
                 $q->whereIn($rel->getTable()->getIdentifier(), $ids);
             }
             $q->execute();
         }
     }
     if (isset($this->_references[$alias])) {
         foreach ($this->_references[$alias] as $k => $record) {
             if (in_array(current($record->identifier()), $ids)) {
                 $this->_references[$alias]->remove($k);
             }
         }
         $this->_references[$alias]->takeSnapshot();
     }
     return $this;
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:39,代码来源:Record.php


注:本文中的Doctrine_Query::whereIn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。