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


PHP Query::andWhere方法代码示例

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


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

示例1: getQuery

 public function getQuery()
 {
     $query = new Query(Yii::app()->db);
     $query->from('groupon as g');
     if ($this->id) {
         $query->andWhere('g.id=:id', array(':id' => $this->id));
     }
     if ($this->title) {
         $query->andWhere(array('like', 'g.title', '%' . $this->title . '%'));
     }
     if ($this->state) {
         $now = time();
         switch ($this->state) {
             case 'online':
                 //在线
                 $query->andWhere('g.begin_time<=:time and g.end_time>=:time', array(':time' => $now));
                 break;
             case 'offline':
                 //下线
                 $query->andWhere('g.end_time<:time', array(':time' => $now));
                 break;
             case 'beonline':
                 //即将上线
                 $query->andWhere('g.begin_time>:time', array(':time' => $now));
                 break;
             default:
                 break;
         }
     }
     return $query;
 }
开发者ID:yinhe,项目名称:yincart,代码行数:31,代码来源:SellGrouponSFM.php

示例2: getCateName

 /**
  * 根据分类id获取分类名
  * @param type $id
  * @param type $level
  * @return type
  */
 public static function getCateName($id, $level = null)
 {
     $query = new Query(Yii::app()->db);
     $query->select('name');
     $query->from('groupon_cates');
     $query->andWhere('id=:id', array(':id' => $id));
     if ($level) {
         $query->andWhere('level=:level', array(':level' => $level));
     }
     $name = $query->queryScalar();
     return $name;
 }
开发者ID:yinhe,项目名称:yincart,代码行数:18,代码来源:ARCates.php

示例3: addCondition

 /**
  * Функция добавления условий поиска.
  * @param Query $query Экземпляр выборки.
  * @param string $attribute Имя отрибута по которому нужно искать.
  * @param boolean $partialMatch Тип добавляемого сравнения. Строгое совпадение или частичное.
  */
 protected function addCondition($query, $attribute, $partialMatch = false)
 {
     $value = $this->{$attribute};
     if (trim($value) === '') {
         return;
     }
     if ($partialMatch) {
         $query->andWhere(['like', $attribute, $value]);
     } else {
         $query->andWhere([$attribute => $value]);
     }
 }
开发者ID:alexandrSS,项目名称:site.loc,代码行数:18,代码来源:UserSearch.php

示例4: getQuery

 public function getQuery()
 {
     $query = new Query(Yii::app()->db);
     $query->select('id,biz_id,name,city_id,area_id,is_reservation');
     $query->from('groupon_biz_shop');
     if ($this->biz_id) {
         $query->andWhere('biz_id=:bid', array(':bid' => $this->biz_id));
     }
     if ($this->name) {
         $query->andWhere(array('like', 'name', '%' . $this->name . '%'));
     }
     return $query;
 }
开发者ID:yinhe,项目名称:yincart,代码行数:13,代码来源:SellShopSFM.php

示例5: getQuery

 public function getQuery()
 {
     $query = new Query(Yii::app()->db);
     $query->from('groupon_biz');
     $query->andWhere('display=' . ARBiz::DISPLAY);
     if ($this->id) {
         $query->andWhere('id=:id', array(':id' => trim($this->id)));
     }
     if ($this->title) {
         $query->andWhere(array('like', 'title', '%' . $this->title . '%'));
     }
     if ($this->status) {
         $query->andWhere('examine_status=:status', array(':status' => $this->status));
     }
     $query->order('id desc');
     return $query;
 }
开发者ID:yinhe,项目名称:yincart,代码行数:17,代码来源:SellBizSFM.php

示例6: getAreas

 /**
  * 获取子市区的键值对列表
  * @param int/null $pid 父ID
  * @param int $grade 等级
  * @return array
  */
 public static function getAreas($pid = null, $grade = self::GRADE_PROVINCE)
 {
     $key = 'arealist_' . $grade . '_' . $pid;
     $areas = Yii::app()->cache->get($key);
     //        dump($areas);
     if ($areas === false) {
         $query = new Query(Yii::app()->db);
         $query->select('id,name');
         $query->from('area');
         if ($pid == null) {
             $query->andWhere('parent_id is null');
         } else {
             $query->andWhere('parent_id=:pid', array(':pid' => $pid));
         }
         $areas = $query->queryAll();
         if (!empty($areas)) {
             $areas = A::map($areas, 'id', 'name');
         }
         Yii::app()->cache->set($key, $areas, 60 * 60 * 24);
     }
     //        dump($areas);
     return $areas;
 }
开发者ID:jackycgq,项目名称:advanced,代码行数:29,代码来源:ARArea.php

示例7: actionAutocomplete

 public function actionAutocomplete($search = null, $id = null, $object_id = null)
 {
     /**
      * @todo Добавить отображение вложенности
      */
     $out = ['more' => false];
     if (!is_null($search)) {
         $query = new Query();
         $query->select(Property::tableName() . '.id, ' . Property::tableName() . '.name AS text')->from(Property::tableName())->andWhere(['like', Property::tableName() . '.name', $search])->limit(100);
         if (!is_null($object_id)) {
             $query->leftJoin(PropertyGroup::tableName(), PropertyGroup::tableName() . '.id = ' . Property::tableName() . '.property_group_id');
             $query->andWhere([PropertyGroup::tableName() . '.id' => $object_id]);
         }
         $command = $query->createCommand();
         $data = $command->queryAll();
         $out['results'] = array_values($data);
     } elseif ($id > 0) {
         $out['results'] = ['id' => $id, 'text' => Property::findOne($id)->name];
     } else {
         $out['results'] = ['id' => 0, 'text' => Yii::t('app', 'No matching records found')];
     }
     echo Json::encode($out);
 }
开发者ID:ar7n,项目名称:dotplant2,代码行数:23,代码来源:PropertiesController.php


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