2016-09-06 12 views
0

私のアプリケーションで問題が発生しています。まず、それが到達した今までにとき私は今挿入後に行の値を取得できません

$data = array(
    'prjc_stno' => $studentData['Student_id'], 
    'prjc_roll_num' => $studentData['roll_num'], 
    'prjc_program_id' => $post_data['program_id'], 
    'prjc_year' => $year, 
); 
$this->db->insert('i_m_studts', $data); 
$last_insert_id = $this->db->insert_id(); 

$data = array(
    'prjc_stdnt_id' => $last_insert_id, 
    'prjc_course_id' => $post_data['course_id'], 
    'prjc_cousem_id' => $crs_semister, 
    'prjc_event' => $post_data['event'], 
    'prjc_event_year' => $year, 
    'prjc_stu_crs_random_id' => $studentData['random_id'], 
    'prjc_no_scan' => 1 
); 
$this->db->insert('i_studt_course', $data); 
$inserted_id = $this->db->insert_id();  

$this->db->trans_start(); 
$this->db->where('prjc_stdnt_id', $inserted_id); 
$this->db->where('prjc_course_id', $post_data['course_id']); 
$this->db->where('prjc_event', $post_data['event']); 
$this->db->where('prjc_event_year', $year); 
$query2 = $this->db->get('i_studt_course'); 

$student_course = $query2->result_array(); 
    --> $prjc_stu_cou_id = $student_course[0]['prjc_stu_cou_id']; **(Line Number: 420)** 

$this->db->where('prjc_stu_crs_id', $prjc_stu_cou_id); 
$query1 = $this->db->get('i_m_scnbb'); 
$result = $query1->result_array(); 

以下のコードを表示してみましょう - >それは$student_course[0]['prjc_stu_cou_id']がnull

である私は理由を知りたいというエラーが作成されます。それが明確でない場合は、お尋ねください。

$student_course = $this->db->select("*") 
     ->from("i_studt_course") 
     ->where("id", $inserted_id) 
     ->limit(1) 
     ->get() 
     ->row_array(); 

は、その後、あなたがして行にアクセスすることができます:

$prjc_stu_cou_id = $student_course["prjc_stu_cou_id"]; 

それはより簡単な解決策は、あなたがしようとしたこと、である

答えて

0

は、私はあなたの行の値を取得するためのより良いオプションをお勧めします。挿入メソッドが成功した場合、このクエリは行データを取得します。

関連する問題