tp5 even when the table query, where the statement conflicts

 

Make-table query even today, I found will be reported this condition is not clear where the statement added sql error, a bit ignorant,

Rummaging some information, which is found in two tables have the same field names, I did not specify what the condition where tables of the field.

Modify the following code to where you can

$where = array(
    'a.store_id' => $storeId,
    'a.goods_user_status' => 1,
);

 

index function public ()
{
// get the current store ID
$ UID = the session ( 'home_uid');
$ storeId DB = ( 'Store') -> WHERE ( 'store_uid', $ UID) -> Field ( 'store_uid') -> Find ();
$ = storeId The implode ( "", $ storeId);
$ storeId = (int) $ storeId;
$ WHERE = Array (
'a.store_id' => $ storeId,
'a.goods_user_status' =>. 1 ,
);
// all goods
$ goodsRes = Db ( 'goods')
-> Alias ( 'A')
-> the Join ( 'goods_class B', 'a.class_id = b.class_id', 'the LEFT') // product Categories
-> join ( 'store_class c' , 'a.store_class_id = c.class_id', 'LEFT') // store categories in the personal shop of
-.> field ( 'a * , b.class_name, c.class_name as store_class_name')
->where($where)
->order('goods_id desc')
->paginate(10);

$this->assign([
'seo_title'=> '店铺商品-' . config('site.WEB_TITLE'),
'seo_keywords'=> config('site.WEB_KEYWORDS'),
'seo_desc'=> config('site.WEB_DESCRIPTION'),
'goodsRes' => $goodsRes,
]);
return $this->fetch('seller_goods/index');
}

Guess you like

Origin www.cnblogs.com/seanpan/p/11365546.html