我在codeigniter中執行以下查詢,無法弄清楚如何讓第二個查詢工作。我如何從我的第一個查詢中獲取一組值,並在第二個查詢中使用這些值?Codeigniter數據庫查詢問題
function application()
{
$user_id = $this->tank_auth->get_user_id();
$this->db->select('app_id')->from('using')->where('user_id' , $user_id);
$query = $this->db->get();
$row = $query->result_array();
if ($query->num_rows() > 0) :
$this->db->select('app_name')->from('applications')->where('id' , $row['app_id']);
$body['query'] = $this->db->get();
endif;
$this->load->view('apps_view', $body);
如果我註釋掉第二個查詢和var_dump($row);
它給我: 陣列(2){[0] =>數組(1){[「APP_ID」] =>串(1)「2 「} [1] => array {1} {[」app_id「] => string(1)」3「}}
我決定做多個查詢而不是連接,因爲我將添加額外的列從第二個查詢中選擇。
感謝您的幫助。
什麼第二個查詢的回報? – 2011-02-14 17:41:15