$n = new Model(User);
$arr = $n -> where("id = 24 and username = '信息学院'") -> find();
$n = new Model(User);
$data['username'] = ?;
$arr = $n -> where($data) -> find();
_*注意:find方法只能查询出一条语句,要想查询多条数据,使用select方法*
GT 大于 greater than
EQ 等于 equal
LT 小于 less than
EGT 大于等于
ELT 小于等于
NEQ 不等于 not equal
LIKE NOTLIKE //必须没有空格
BETWEEN
NOT BETWEEN //必须有空格
IN
NOT IN //必须有空格
$n = new Model(User);
$data['id'] = array('GT',20);
$arr = $n -> where($data) -> select();
var_dump();
$n = new Model(User);
$data['username'] = array('like',"%中%");
$arr = $n -> where($data) -> select();
var_dump($arr);
$n =new Model(User);
$data['username'] = array('like',array('%中%','%学%'));//或者的关系,为默认值 $data['username'] = array('like',array('%中%','%大%',%学%'),'and');
$arr = $n -> where($data) -> select(); var_dump($arr);
$n = new Model(User);
$data['id'] = array('between',array(1,20));
$arr = $n -> where($data)->select();
var_dump();
$n = new Model(User);
$data['id'] = array('not between',array(1,20));
$arr = $n -> where($data)->select();
var_dump();
$n = new Model(User);
$data['id'] = array('in',array(2,6,7));
$arr = $n -> where($data) -> select();
var_dump();
$n = new Model(User);
$data['id'] = array('not in',array(2,6,7));
$arr = $n -> where($data) -> select();
var_dump();
$n = new Model(User);
$arr = $n -> where($data) -> select(); var_dump();
$data['username'] = array(array('like','%中%'),array('like','%学%'),'or');
$n = new Model(User);
$n -> count();
$n = new Model(User);
$n -> max('id');
$n = new Model(User);
$n -> min('id');
$n = new Model(User);
$n -> avg('id');
@sum $n = new Model(User);
$n -> sum('id');
用于读取数据,成功返回数据的结果集即数组,失败则返回boolean false
$n = new Model();
$result = $n -> query("select * from tp_user where id > 20");
var_dump($result);
用来更新数据的操作,成功则返回影响的行数,不成功则返回boolean false
$n = new Model();
$result = $n -> execute("insert into tp_user(username) values('朱传波')");//不要有在字段名之前加引号
$result = $n -> execute("insert into tp_user values('','朱传波','1')") var_dump($result);
$arr = $m -> order('id desc') -> select();
$arr = $m -> order(array('id' => 'desc','sex' => 'asc')) -> select();
limit(2,5);
limit('2,5');
limit(10)//limit(0,10);
field('username as name,id');//将username的名称设为name
field(array('username' => 'name','id'));
field('id',true);*/