| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\admin\model;
- use think\Model;
- /**
- * 智能问答模型
- */
- class Robot extends Model
- {
- /**
- * select数据筛选
- *
- * @access public
- * @param mixed $field 字段
- * @param mixed $join 关联
- * @param mixed $where 条件
- * @param mixed $offset 分页开始
- * @param mixed $limit 分页大小
- * @param mixed $order 排序
- * @return array 返回类型
- */
- public function selectJoin($field, $join, $where=[], $offset='', $limit='', $order=['robot_updateTime'=>'desc'])
- {
- $result = $this->field($field);
- if (empty($join) === false) {
- $result = $result->alias('a');
- foreach ($join as $k => $v) {
- $result = $result->join($k, $v);
- }
- }
- if (empty($where) === false) {
- $result = $result->where($where);
- }
- if (empty($offset) === false && empty($limit) === false) {
- $result = $result->limit($offset, $limit);
- }
- if (empty($order) === false) {
- foreach ($order as $k => $v) {
- $result = $result->order($k, $v);
- }
- }
- $result = $result->select();
- return $result;
- }//end selectJoin()
- /**
- * select数据筛选
- *
- * @access public
- * @param mixed $where 条件
- * @return array 返回类型
- */
- public function count($where=[])
- {
- $result = $this;
- if (empty($where) === false) {
- $result = $result->where($where)->count();
- }else{
- $result = $result->where($where)->count();
- }
- return $result;
- }//end count()
- }
|