使用Codeigniter活动记录重写MySQL查询
我不久前就开始使用CodeIgniter。有人能告诉我如何重写这个查询吗使用Codeigniter活动记录重写MySQL查询,mysql,codeigniter,activerecord,codeigniter-2,Mysql,Codeigniter,Activerecord,Codeigniter 2,我不久前就开始使用CodeIgniter。有人能告诉我如何重写这个查询吗 SELECT question.timestamp AS question_time, reply.timestamp AS reply_time, (SELECT DATEDIFF(reply_time, question_time)) AS time_used_to_reply FROM question JOIN reply ON question.id = reply.question_id WHERE que
SELECT question.timestamp AS question_time, reply.timestamp AS reply_time,
(SELECT DATEDIFF(reply_time, question_time)) AS time_used_to_reply
FROM question JOIN reply ON question.id = reply.question_id WHERE question.company_id=someid
使用activerecord
此外,任何能快速理解activerecord的教程都将不胜感激。谢谢经过多次研究,我终于写下了自己的活动记录脚本
$this->db->select(array('DATEDIFF(reply.timestamp, question.timestamp)'))
->from('question')
->join('reply', 'question.id = reply.question_id')
->where('question.company_id', $company_id);
谢谢经过多次研究,我终于写下了自己的活动记录脚本
$this->db->select(array('DATEDIFF(reply.timestamp, question.timestamp)'))
->from('question')
->join('reply', 'question.id = reply.question_id')
->where('question.company_id', $company_id);
谢谢