gpt4 book ai didi

php - codeigniter 检查同一表中不同表中可用的 id

转载 作者:行者123 更新时间:2023-11-28 23:12:39 24 4
gpt4 key购买 nike

在需要检查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 表中。请检查一次并建议我如何操作

最佳答案

您可以添加以下语句以获得所需的输出。

$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);

关于php - codeigniter 检查同一表中不同表中可用的 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45252864/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com