分页
分页 paginate 获取数据后,对对象添加数据(5.0、5.1):
$orders = Db::name('order')->paginate()->each(function($value, $key) use ($snap) {
$value['additional_str'] = 'additional_string';
if ($snap == 1) $value['snaps'] = 'this is test string';
return $value;
});
模板分页含参数:
$query->paginate(['query' => Request()->param()]);
$query->paginate(12, false, ['query' => Request()->param()]);
$query->paginate(12, false, ['query' => ['demo' => $demo, 'demo2' => 'demo2']]);
模板截取字符串
# version 5.1、6.0
{{$vo.description|mb_substr=0,30,'utf-8'}}
{{:mb_strlen($vo.description) > 50 ? mb_substr($vo.description, 0, 50, 'utf-8').'...' : $vo.description}}
{{$vo.create_time|substr=0,10}}
concat使用
1,tp5.1 update concat 使用示例:
// child_ids字段拼接
Db::name('category')->where('id', $value)->update(['child_ids' => Db::raw('concat(child_ids, "123")')]);