标签:设置 cond bsp find data col sele search condition
$criteria = new CDbCriteria(); // 查询字段 $criteria->select = ‘id, name, create_time‘; // 排序 $criteria->order = ‘create_time DESC‘; // 条件筛选 and $criteria->addCondition(‘id = 1‘); // 模糊筛选,相当于like $criteria->addSearchCondition(‘name‘, ‘筛选内容‘); // in 筛选 $criteria->addInCondition(‘id‘, [‘1‘, ‘2‘, ‘3‘]); // join 关联查询,user是模型里relations方法中设置的相对应的表 $criteria->with = [‘user‘]; // 查询满足条件的总条数 $count = model::model()->count($criteria); // 实现分页 $pager = new CPagination($count); // 每页显示数量 $pager->pageSize = 20; $pager->applyLimit($criteria); // 查询满足条件的数据 $data = model::model()->findAll($criteria);
标签:设置 cond bsp find data col sele search condition
原文地址:https://www.cnblogs.com/woods1815/p/10259278.html