请教TP3.2.3 D方法的疑问

浏览:3789 发布日期:2014/12/29 分类:求助交流 关键字: thinkphp3.2.3
控制器//流量统计
    public function visit(){
        $Product = M('Product');
        $Viewcount = M('ViewCount');
        $Order = M('Order');
        $model = D('Count');
        //得到产品数据
        $data = $Product->field('id,name')->select();
        foreach ($data as &$va){
            $va['Product'] = $model->getProductVisit($va['id']);
            $va['Order'] = $model->getProductOrder($va['id']);
        }
        $this->assign('data',$data);
        $this->display();
    }
模型<?php
namespace Admin\Model;
use Think\Model;
class CountModel extends CommonModel {
    
    /**
     * 获取产品流量
     * @param  intval $pid 产品ID
     * @return array
     */
    public function getProductVisit($pid = 0){
        if (!$pid) return;
        $db = M('ViewCount');
        $arr = $db->where('pid = '.$pid)->select();
        $arr['views'] = $db->where('pid = '.$pid)->SUM('views');
        $arr['yesterdayviews'] = $db->where('pid = '.$pid)->SUM('yesterdayviews');
        $arr['dayviews'] = $db->where('pid = '.$pid)->SUM('dayviews');
        $arr['weekviews'] = $db->where('pid = '.$pid)->SUM('weekviews');
        $arr['monthviews'] = $db->where('pid = '.$pid)->SUM('monthviews');
        return $arr;
    }
    /**
     * 获取产品订单
     * @param  intval $pid 产品ID
     * @return array
     */
    public function getProductOrder($pid){
        if (!$pid) return;
        $db = M('Order');
        //$arr = $db->where('pid = '.$pid)->select();
        $arr['all_order'] = $db->where('pid = '.$pid)->count('id');
        $map['pid'] = $pid;
        $map['status'] = array('not in',array('0','1','-1'));
        $arr['send_order'] = $db->where($map)->count();
        $arr['fx_order'] = $db->where('status = 5 AND pid = '.$pid)->count();
        $arr['jq_order'] = $db->where('status = -3 AND pid = '.$pid)->count();
        $arr['qx_order'] = $db->where('status = -1 AND pid = '.$pid)->count();
        $arr['qs_per'] = floor(($arr['fx_order']/$arr['send_order'])*10000)/10000*100 . '%';
        $arr['jq_per'] = floor(($arr['jq_order']/$arr['send_order'])*10000)/10000*100 . '%';
        
        
        return $arr;
    }
}
数据库中是没有这个表的。

运行就出现

SQLSTATE[42S02]: base table or view not found: 1146 Table 'data.cms_crm' doesn't exist

在TP3.2.2的时候是能正常运行的啊
最佳答案
评论( 相关
后面还有条评论,点击查看>>