在需要检查del id的项目中工作是否在liked
表中。
b.deal_available_city,
b.shippingType,b.priceType,b.dealId,b.dealUrl,b.dealTitle,b.slug,b.dealDetails,b.extraDetails,b.isHomeScreenBigDeal,b.deal_available_city,
b.aditionalDetails,b.status,b.dateAdded,b.categoryId,b.siteId,b.isPinned,b.priceId,b.price,b.startDate,b.endDate,b.NumberOfClicked,b.discountPrice,b.discountPercentage,b.dealBrandId,
b.endTime,b.startTime,b.howtousethisoffer,b.deal_location,b.cancellationpolicy,b.dealType,b.totalavailabledeals,b.numberofdealused,
b.addedTime,i.thumbImage,i.imageUrl,i.normalimageurl,s.SiteUrl,s.SiteName,s.Site_alias,s.SiteLogo,c.cat_name,c.cat_color,c.cat_alias,p.price_name,
p.price_symbol,p.price_shortcode,st.shId,st.shipping_text
$this->db->from('dealdetails as b');
$this->db->join('dealImages i', 'i.dealId = b.dealId','left');
$this->db->join('brand s', 's.SiteId = b.siteId','left');
$this->db->join('shipping_details st', 'st.shId = b.shippingType','left');
$this->db->join('price_type p', 'p.id = b.priceId','left');
$this->db->join('coupon_category c', 'c.catId = b.categoryId','left');
//$this->db->join('dealfavorite l', 'l.id = b.dealId','left');
$this->db->where('b.showinhomescreen','1');
$this->db->where('i.imgisdefault','1');
$this->db->where('i.status','1');
$this->db->where("FIND_IN_SET(".$this->input->cookie('city', TRUE).",b.deal_available_city) !=", 0);
$this->db->where('b.startTime <=',date('Y-m-d H:i:s'));
$this->db->where('b.endTime >= ',date('Y-m-d H:i:s'));
$this->db->group_by('b.dealId');
$this->db->order_by("b.dealId", "desc");
现在的情况就是需要检查id是否在liked
表中。请检查一次,并建议我如何做的方式
答案 0 :(得分:1)
您可以添加以下语句以获得所需的输出。
$this->db->join('dealfavorite l', 'l.deal_id = b.dealId AND l.user_id = '.$logedinUser,'left');
要获取收藏状态,您可以添加select
,如下所示。
$this->db->select("*, if(l.user_id>0,'Yes','No') as favorite" , FALSE);