首页 > 解决方案 > 为什么从 codeigniter 2.6 迁移到 codeigniter 3 后出现 DB 错误?

问题描述

为什么从 CodeIgniter 2.6 迁移到 CodeIgniter 3 后出现 DB 错误?

它在表名后添加“,0”。

Ex- SELECT id, title, title_urlFROM tablename, 0 WHERE isEnabled= 'Y' ORDER BY dateDESC LIMIT 1

标签: codeigniter-3

解决方案


public function functionName()
{
    $this->db->select('id, title, title_url');
    $this->db->from('tablename');
    $this->db->where('isEnabled','Y');
    $this->db->order_by('date','desc');
    $this->db->limit(1); 
    $query = $this->db->get()->result();
    return $query;
}

试试这个。


推荐阅读