thinkphp5.1 关联查询多表查询
控制器代码:
<?php
$goods_rs=Db::name('goods')
->field('a.id,a.title,b.sid,b.price')
->alias('a')
->join('goodsPic b','a.id = b.sid')
->where('a.pid',$rs['sid'])
->where('a.flid',2)
->select();
$this->assign('goods_rs',$goods_rs);
模版代码:
<div class="layui-form-item">
{volist name="goods_rs" id="goods"}
<div class="layui-inline">
<label class="layui-form-label">{$goods.title}</label>
<div class="layui-input-inline">
<input type="hidden" name="sid2[]" value="{$goods.id}" />
<input name="price[]" lay-verify="required" autocomplete="off" class="layui-input" type="text" value="{$goods.price}" />
</div> {/volist}
</div>