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


PHP Query::orWhere方法代码示例

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


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

示例1: testWhere

 public function testWhere()
 {
     $query = new Query();
     $query->where('id = :id', [':id' => 1]);
     $this->assertEquals('id = :id', $query->where);
     $this->assertEquals([':id' => 1], $query->params);
     $query->andWhere('name = :name', [':name' => 'something']);
     $this->assertEquals(['and', 'id = :id', 'name = :name'], $query->where);
     $this->assertEquals([':id' => 1, ':name' => 'something'], $query->params);
     $query->orWhere('age = :age', [':age' => '30']);
     $this->assertEquals(['or', ['and', 'id = :id', 'name = :name'], 'age = :age'], $query->where);
     $this->assertEquals([':id' => 1, ':name' => 'something', ':age' => '30'], $query->params);
 }
开发者ID:glcode,项目名称:yii2-2.0.3-annotated,代码行数:13,代码来源:QueryTest.php

示例2: run

 /**
  * @return array
  * @throws yii\web\NotFoundHttpException
  */
 public function run()
 {
     if (!isset($_GET[$this->query_variable])) {
         throw new yii\web\NotFoundHttpException();
     }
     $modelName = $this->modelName;
     Yii::$app->response->format = yii\web\Response::FORMAT_JSON;
     $query = new yii\db\Query();
     $query->select($this->json_attributes)->from($modelName::tableName());
     $search_query = $_GET[$this->query_variable];
     foreach ($this->search_attributes as $attribute) {
         $query->orWhere(['like', $attribute, $search_query]);
     }
     $suggest = $query->limit($this->limit)->all();
     return $suggest;
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:20,代码来源:AutocompleteAction.php

示例3: ur_l

 public function ur_l()
 {
     $db = new Query();
     if ($_POST['search']['value'] != "") {
         $db->where(['like', 'name', $_POST['search']['value']]);
         $db->orWhere(['like', 'address', $_POST['search']['value']]);
         $db->orWhere(['like', 'inn', $_POST['search']['value']]);
         $db->orWhere(['like', 'wabc', $_POST['search']['value']]);
     }
     if (is_numeric($_POST['region'])) {
         $db->InnerJoin('region_ur_l', 'id_ur = ur_l.id');
         $db->andWhere(['=', 'id_reg', $_POST['region']]);
     }
     if ($_POST['pharmopeka']) {
         $db->andWhere(['=', 'ur_l.farmopeka', '1']);
     }
     if ($_POST['order'][0]['column']) {
         $column_order = $_POST['order'][0]['column'];
         $column = $_POST['columns'][$column_order]['data'];
         $db->orderBy($_POST['columns'][$column_order]['data'] . " " . $_POST['order'][0]['dir']);
     }
     if (Yii::$app->user->identity->status == 2) {
         //Регионалы
         $db->andFilterWhere(['=', 'ur_l.regional_id', Yii::$app->user->identity->id]);
     }
     if (Yii::$app->user->identity->status == 3) {
         //Провизоры
         $db->andFilterWhere(['=', 'ur_l.pi_id', Yii::$app->user->identity->id]);
     }
     $db->from('ur_l');
     $db->select(['ur_l.name', 'ur_l.id', 'ur_l.inn', 'ur_l.address', 'ur_l.wabc']);
     $db->limit(10);
     $db->offset(intval(Yii::$app->request->post('start')));
     $data = $db->all();
     $count = $db->count();
     for ($i = 0; $i < count($data); $i++) {
         $data[$i]['name'] = "<a href=\"/ur/update?id=" . $data[$i][id] . "\">" . $data[$i][name] . "</a>";
         $data[$i]['id'] = "<a href=\"/ur/update?id=" . $data[$i][id] . "\">" . $data[$i][id] . "</a>";
     }
     $array = array('draw' => intval(Yii::$app->request->post('draw')), 'recordsTotal' => $count, 'recordsFiltered' => $count, 'data' => $data);
     return $array;
 }
开发者ID:pumi11,项目名称:aau,代码行数:42,代码来源:MyJson.php


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