本文整理汇总了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);
}
示例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;
}
示例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;
}