【问题标题】:Distinct use in codeigniter在 codeigniter 中的不同用途
【发布时间】:2012-01-20 16:48:28
【问题描述】:

我在 codeigniter 中有以下查询 这个想法是只获得不同的行 - 我要使用它的列称为 club_id - 任何想法如何在 codeigniter 中执行此操作,因此每个 club_id 只显示一个优惠?

$this->db->distinct();
$this->db->limit($limit);
$this->db->where("UNIX_TIMESTAMP(`end_date`) > ".time());
$q = $this->db->get('offers');

【问题讨论】:

    标签: php mysql codeigniter frameworks


    【解决方案1】:

    只需在 select 方法中添加列,如下所示

    $this->db->distinct();
    $this->db->select("club_id")
    $this->db->limit($limit);
    $this->db->where("UNIX_TIMESTAMP(`end_date`) > ".time());
    $q = $this->db->get('offers');
    

    【讨论】:

    • 如果这是 Gaz 的要求,那么这是正确的。我不知道 Gaz 是否想加入俱乐部餐桌。 +1 给你。
    猜你喜欢
    • 2020-06-12
    • 1970-01-01
    • 2021-11-19
    • 2023-03-22
    • 2019-04-09
    • 2011-02-12
    • 1970-01-01
    • 1970-01-01
    • 2021-04-23
    相关资源
    最近更新 更多