GoodsCategoryController.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\model\GoodsCategoryModel;
use app\portal\model\GoodsModel;
use cmf\controller\HomeBaseController;
use EasyWeChat\Foundation\Application;
use think\Db;
class GoodsCategoryController extends HomeBaseController
{
public function index()
{
// $data=Db::name('goods_category')->where('id',1)->find();
// var_dump($data);
$goodsCategory=new GoodsCategoryModel();
//数据查询
// $data=$goodsCategory::get('8');
// var_dump($data->create_time);
// $data= $goodsCategory::all();
// foreach($data as $key=>$user){
// echo $user->name;
// }
// $goodsCategory::chunk(2,function($data) {
// foreach($data as $goods){
// // 处理user模型对象
// $goods::where('name','测试分类22')->update(['content'=>'2']);
// }
// });
//数据添加
$data=['name'=>'测试分类22','content'=>'22222222','??'=>'??'];
// $result=$goodsCategory->allowField(true)->save($data);
// $result=$goodsCategory::create($data,true);
// var_dump($result->id);
//数据更新
// $result=$goodsCategory->isUpdate(true)->allowField(true)->save($data,['id'=>1]);
// $result=$goodsCategory::where('id',1)->update(['content'=>'1111111']);
// $result=$goodsCategory::update($data,['id'=>1],true);
//数据删除
// $result=$goodsCategory::destroy(['name'=>'测试分类22']);
// $result=$goodsCategory::destroy(function ($query){
// $query->where('id',8);
// });
}
}