根据sql查询
$sql ="select * from test where id = 1" ;
Test ::findBySql ($sql) ->all();
根据sql查询,防止sql注入
$sql ="select * from test where id = :id" ;
Test::findBySql ($sql, array(':id' =>'1')) ->all();
不根据sql
查询id为1的记录
$result =Test:: find()-> where(['id' =>1]) ->all();
查询id大于1的记录
$result =Test:: find ()-> where (['>','id', 1]) -> all();
查询id>=1并且<=5的记录
$result =Test:: find ()->where (['between' ,'id', 1,5])-> all();
查询 select * from test where title like "%title1%"
$result =Test:: find ()->where (['like' ,'title','title1'])->all();
来自于datou:https://github.com/datou-leo/ci