视图为什么得不到getLastSql
1个回答
推荐于2016-04-25 · 知道合伙人软件行家
关注
展开全部
视图模型文件名:GoodsViewModel.class.php
内容如下:
<?php
namespace Home\Model;
use Think\Model\ViewModel;
class GoodsViewModel extends ViewModel
{
public $viewFields = array(
'Goods' => array('id','shopid','goodsid','taobaoid','img','title','price','date','cat','_table'=>"fruit_shop_goods"),
'Shop' => array('id' => 'shop_id', '_on' =>'Goods.shopid=Shop.uid'),
);
}
?>
controller中:
layout(true);
$goods = D('GoodsView');
//dump($goods);
//$where=array('id'=>1);
$gds = $goods->select();
echo ($gds->getLastSql);
//dump($gds);
die;
内容如下:
<?php
namespace Home\Model;
use Think\Model\ViewModel;
class GoodsViewModel extends ViewModel
{
public $viewFields = array(
'Goods' => array('id','shopid','goodsid','taobaoid','img','title','price','date','cat','_table'=>"fruit_shop_goods"),
'Shop' => array('id' => 'shop_id', '_on' =>'Goods.shopid=Shop.uid'),
);
}
?>
controller中:
layout(true);
$goods = D('GoodsView');
//dump($goods);
//$where=array('id'=>1);
$gds = $goods->select();
echo ($gds->getLastSql);
//dump($gds);
die;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询