thinkphp 如何写这样的代码 find();
$sql="SELECTa.attr_nameFROMecs_attributeASa,ecs_goods_attrASga,ecs_goodsASgWHEREa.att...
$sql = "SELECT a.attr_name FROM ecs_attribute AS a, ecs_goods_attr AS ga, ecs_goods AS g WHERE a.attr_id = ga.attr_id AND g.goods_id = ga.goods_id AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND a.attr_id='$value'";
if($temp_name = $db->getOne($sql))
请问用thinkphp find 怎么写
一般是这样
$M3 = M("ecs_brand");
$brand = $M3->field("`brand_id`,`brand_name`")->where("brand_id=" . (int) $brand_id)->find();
这种复杂的不会写啊,求帮助 展开
if($temp_name = $db->getOne($sql))
请问用thinkphp find 怎么写
一般是这样
$M3 = M("ecs_brand");
$brand = $M3->field("`brand_id`,`brand_name`")->where("brand_id=" . (int) $brand_id)->find();
这种复杂的不会写啊,求帮助 展开
2个回答
展开全部
M()->table('ecs_attribute a')->join('ecs_goods_attr ga on a.attr_id=ga.attr_id')->join('ecs_goods g on ga.goods_id=g.goods_id')->where("g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND a.attr_id='$value'")->find();
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询