我在使用codeigniter加入这两个数据库时出现问题,我使用mysql尝试了它并且有效。
有人可以将其转换为codeigniter
这是我的代码
SELECT DATE_FORMAT(FROM_UNIXTIME(ex.extime), '%Y-%m-%d') as `export_report`, u.username as `Username`, ex.qdesc as `Search_Performed`,
ex.to as `Number_of_records_exported`, ex.format as `Format`
FROM cone.users u
INNER JOIN igdata.export_status as ex
ON u.id = ex.uid
WHERE DATE_FORMAT(FROM_UNIXTIME(ex.extime), '%Y-%m-%d') = '{$dateToday}'
ORDER BY u.username ASC
我也把它放在我的构造函数
中private $cone_read;
private $ixdata;
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->cone_read = $this->load->database('cone_read', TRUE);
$this->ixdata = $this->load->database('cone_us', TRUE);
}
答案 0 :(得分:0)
试试这个:
$this->db->select("DATE_FORMAT(FROM_UNIXTIME(ex.extime), '%Y-%m-%d') as export_report, u.username as Username, ex.qdesc as Search_Performed, ex.to as Number_of_records_exported, ex.format as Format");
$this->db->from('cone.users u');
$this->db->join('igdata.export_status as ex', 'u.id = ex.uid');
$this->db->where("DATE_FORMAT(FROM_UNIXTIME(ex.extime), '%Y-%m-%d') = '$dateToday'");
$this->db->order_by("u.username", "asc");
$query = $this->db->get();