2012-12-14 95 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); 

感謝

相關問題