douming4359 2014-06-23 12:29
浏览 19
已采纳

以Codeigniter格式转换查询

I have a query

SELECT        l.id,l.name,l.city,l.email,l.phone,l.status,l.source,l.leadCreatedTime,l.organizationId
FROM    (
    SELECT  id
    FROM    leads
where removed='0'
    ORDER BY
            id
    LIMIT 40000
    ) o
JOIN    leads l
ON      l.id = o.id
ORDER BY
    l.id

I want to convert this query in Codeigniter format for eg

$this->db->select('l.id,l.name,l.city,l.email,l.phone,l.status,l.source,l.leadCreatedTime,l.organizationId');
$this->db->from('leads');

Im having problem in the 8th line of query where the fetched data is defined as o how am I suppose to write that in CI

  • 写回答

2条回答 默认 最新

  • dongpo0409 2014-06-24 12:55
    关注

    can u test my code it may help you as it is codegniter format

    $this->db- >select('l.id,l.name,l.city,l.email,l.phone,l.status,l.source,l.leadCreatedTime,l.organizationId');
    $this->db->from('(SELECT id FROM leads where removed="0" ORDER BY id LIMIT 40000) o');
    $this->db->join('leads l', 'l.id = o.id');
    $this->db->order_by('l.id');
    $result=$this->db->get();
    $show=$result->result_array();
    

    it is not in fully codeigniter format in sub query but it help you.

    Enjoy code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?