I am trying to invoke 2 consecutive requests in CodeIgniter, the first of which has an order-by clause. The problem is that CodeIgniter is trying to use the order-by clause for the second request and throw an error.
The code looks something like this:
...
$sql = $this->db->get_where('expenses',array('category_id' => $category_id));
$this->db->order_by("date", "asc");
$data = $sql->result_array();
foreach($data as $expense_rec)
{
$expense_id = $data['expense_id'];
$sql2 = $this->db->get_where('expense_details',array('expense_id' => $expense_id));
$detail_rec = $sql2->result_array();
}
...
For the second request, the script throws the following error:
Unknown column 'date' in 'order clause'
SELECT * FROM (`expense_details`) WHERE `expense_id` = '4' ORDER BY `date` asc
Is there a way that I can reset to execute an order before calling the second request?
I am using CodeIgniter 1.7
PS I know that I can join two requests in one, but I'm curious to find out if there is a way for the above code to work in CodeIgniter.
Rahul source
share