Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tp5 最新版 数据集查询后 调用内置分页后 想修改分页过的数据 补充额外字段 #14

Open
yangweijie opened this issue Jul 10, 2017 · 0 comments

Comments

@yangweijie
Copy link
Owner

tp5 最新版 数据集查询后 调用内置分页后 想修改分页过的数据 补充额外字段 可以用collection 的 offsetSet 方法

$productCategory = Db::name('ProductCategory')->alias('a')->field("a.id,a.category_name,a.discount,a.order_index,count(b.id) as product_num")
          ->join('kwy_product b', 'b.product_category_id =a.id', 'left')->where($where)->group("a.id")->order("a.order_index asc")->paginate(10);

        foreach($productCategory->all() as $key =>$val ){
            $productCategory->offsetSet($key, array_merge($val, ['sex'=>1]));
        }

完成获取器的操作 以后可能支持分页类对象的each 方法修改数据

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant