laravel中连表查询

        $skuList = ProductSkuModel::selectRaw('product_skus.id as sku_id,
product_skus.code as code,
product_skus.wname as sku_name,
product_skus.stocks as stocks,
if(`product_skus`.`status`=1,\'上架\',\'下架\') as status,
brands.name as brand,
product_attributes.attribute_name as basic_attribute,
product_attributes.attribute_value_name as basic_attribute_name,
sku_attributes.attribute_name as price_attribute,
sku_attributes.attribute_value_name as price_attribute_name')
->leftJoin('product_attributes', 'product_skus.product_id',
'=', 'product_attributes.product_id')
->leftJoin('sku_attributes', 'product_skus.id',
'=', 'sku_attributes.sku_id')
->leftJoin('brands', 'product_skus.brand_id',
'=', 'brands.id')
->where('sku_attributes.status', 1)
->where('product_attributes.status', 1)
->get()->toArray();
上一篇:Linux C中内联汇编的语法格式及使用方法(Inline Assembly in Linux C)【转】


下一篇:asp.net获取当前页面文件名,参数,域名等方法。统一session验证和权限验证的方法