CodeIgniter使用this-> db->查询分页

时间:2011-01-05 06:49:16

标签: php codeigniter

如何在$ this-> db-> query()方法中使用codeigniter?

如果我使用活动记录类,我会这样做:

$query = $this->db->get('tb_cash_transaction',$num,$offset);
$this->db->order_by("CURRENCY_ID", "asc"); 

现在我正在使用$ this-> db-> query()

$query = "SELECT * FROM tb_cash_transaction, tb_currency, tb_user where tb_cash_transaction.CURRENCY_ID=tb_currency.CURRENCY_ID and tb_cash_transaction.USER_ID=tb_user.USER_ID and TYPE='cash_out'";   
$query = $this->db->query($query);

如何实施?谢谢。

1 个答案:

答案 0 :(得分:2)

尝试使用这个..

$query = "SELECT * FROM tb_cash_transaction, tb_currency, tb_user where tb_cash_transaction.CURRENCY_ID=tb_currency.CURRENCY_ID and tb_cash_transaction.USER_ID=tb_user.USER_ID and TYPE='cash_out' order by CURRENCY_ID asc LIMIT $offset , $num";
$query = $this->db->query($query);

希望这会有帮助。

谢谢!

侯赛因