分页

分页 paginate 获取数据后,对对象添加数据(5.0、5.1):

  1. $orders = Db::name('order')->paginate()->each(function($value, $key) use ($snap) {
  2. $value['additional_str'] = 'additional_string';
  3. if ($snap == 1) $value['snaps'] = 'this is test string';
  4. return $value;
  5. });

模板分页含参数:

  1. $query->paginate(['query' => Request()->param()]);
  2. $query->paginate(12 false, ['query' => Request()->param()]);
  3. $query->paginate(12 false, ['query' => ['demo' => $demo, 'demo2' => 'demo2']]);

模板截取字符串

  1. # version 5.1、6.0
  2. {{$vo.description|mb_substr=0,30,'utf-8'}}
  3. {{:mb_strlen($vo.description) > 50 ? mb_substr($vo.description, 0, 50, 'utf-8').'...' : $vo.description}}
  4. {{$vo.create_time|substr=0,10}}

concat使用

1,tp5.1 update concat 使用示例:

  1. // child_ids字段拼接
  2. Db::name('category')->where('id', $value)->update(['child_ids' => Db::raw('concat(child_ids, "123")')]);