来源: 本站版本: (PHP)JTBC5.0
例如查询一个字段ab的值为$a或$b时,输出结果
就需要添加这样的查询条件来实现
$model -> where(function($where) use ($a,$b){
$where -> ab = $a;
$where -> ab -> or = $b;
});
或者不同字段
$model -> where(function($where) use ($keyword){
$where -> title -> like('%' . $keyword . '%');
$where -> content -> or-> like('%' . $keyword . '%');
});
例子代码
$model = new TinyModel();
$model -> where -> published = 1;
$model -> where -> lang = $lang;
$model -> where(function($where) use ($a,$b){
$where -> ab = $a;
$where -> ab -> or = $b;
});
$model -> orderBy('time', 'desc');
$datas = $model -> getAll();
技术支持QQ:925474725