thinkphp中使用原始SQL语句问题

浏览:4512 发布日期:2013/06/26 分类:求助交流
我的Action中是这样写的,通过主键查找表的明细出来
因为要通过代码查找中文名字出来,所以关联其他表。
输出JSON是有数据的,但在html页面上{$data.pt_id}就不出数据,用$List = $Data->find($id)就有数据显示。
请问是什么原因呢?public function ProductDetail($id) {
    $Data = M("od_cms_product");
    #$List = $Data->find($id);
    $List = $Data->query("select t1.*,t2.type_name,t3.unit_name from od_cms_product t1 
        left join (select code_value,code_text as type_name from od_cms_code where code_id='Class')as t2 on t2.code_value=t1.pt_type
        left join (select code_value,code_text as unit_name from od_cms_code where code_id='Unit')as t3 on t3.code_value=t1.pt_unit
        where t1.pt_id='$id'");        
    $this->data = $List;
    $this->display('Product/productdetail');
    }
最佳答案
评论( 相关
后面还有条评论,点击查看>>