2012-12-14 67 views
0

我不久前就开始使用CodeIgniter。可一些告诉我如何重写此查询使用Codeigniter Active Record重写MySQL查询

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的将是非常赞赏。谢谢

回答

3

经过多次研究,我结束了写我自己的活动记录脚本。

$this->db->select(array('DATEDIFF(reply.timestamp, question.timestamp)')) 
    ->from('question') 
    ->join('reply', 'question.id = reply.question_id') 
    ->where('question.company_id', $company_id); 

感谢

相关问题