继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

进销存项目笔记

手记佰篇
关注TA
已关注
手记 60
粉丝 58
获赞 272

    1、分类求和

public function find()

    {    
         //$data['oders'] = $this->db->table('oders')->order('need_time')->lists();
        //$data['oders']= $this->db->table('oders')->field('name,SUM(price) AS prices')->group('name')->lists();
        $data['oders']= $this->db->table('store')->field('name,SUM(qty) AS qtys')->group('name')->products();
        dump( $data['oders']);
         exit();
        $this->assign('data', $data);
        return $this->fetch();

    }

//$products = $this->db->table('product')->field('name,SUM(price) AS prices')->group('name')->select();
    public function products(){
        $products = Db::name($this->table)->field($this->field)->group($this->group)->select();
        return $products ? $products : false;
    }

2、session

        $admin = $this->db->table('admins')->where(array('username'=>$username))->item();

    session('admin',$admin);

<div class="header">
        <span class="title"><span style="font-size: 12px;">{$site.values}</span>-后台管理系统</span>
        <span class="userinfo">{$admin.username}{$admin.truename}【{$role.title}】<span><a href="javascript:;" ="logout()">退出</a></span></span>
    </div>

3、查询

传空值调用视图Post提交 查询调用视图显示

      public function outfind()
    {
 
        $this->assign('data', '');
        return $this->fetch();
    }

4、7种jion连接之入库

$sql="SELECT *, a.name FROM (select *  from oders where need_time = :time )  a LEFT JOIN (select store_time, name from  store  group by name) b ON a.name = b.name and a.need_time = b.store_time where  store_time is null "; 

$data['price']=Db::query($sql,['time'=>date('Y-m-d') ]);

dump($data['price']);


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP