查询条件怎么写

 


 

等于,大于,小于,不等于

等于

 

$where = [
    'course_id' => 100
];

 

大于,小于,大于等于,小于等于,不等于

 

<、 >、 >=、 <=、 <>

 

$where = [
    'course_id' => ['>', 99],
    'type' => ['<', 2],
    'status' => ['<>', 0]
];
$this->all($where);

 

SQL: WHERE course_id > 99 AND type < 2 AND status <> 0

 

BETWEEN

$where = [
    'course_id' => ['between', 200, 300]
];

 

SQL: WHERE course_id BETWEEN 200 AND 300

 

LIKE

$where = [
    'name' => ['like', '%TimoPHP%']
];

 

SQL: WHERE name LIKE '%TimoPHP%'

 

IN

$where = [
    'course_id' => ['in', '1,3,5,7,9']
];

 

SQL: WHERE course_id IN(1,3,5,7,9)

 

怎样写or条件查询

直接写WHERE条件

$where = '(type > 2 OR status = 3) AND id > 10000';
$userModel = new UserModel();
$users = $userModel->find($where);