1

Please find below code

//--Sec A--
$query = $this->db->insert('test',$insert_data);
$data['test_data'] = $query->result();

// --Sec B--- code to get inserted row

$this->addPanels($panArr,$job_Id,$test_Id);//$test_Id is result of Sec B

echo json_encode($data);//Result of Sec A

I am unable to understand why i am unable to get result of addPanels()

3
  • Please elaborate your question. Commented Apr 7, 2016 at 3:42
  • I am inserting single row in "test" table. I want primary key ($test_Id - auto increment) of inserted row to be used in calling next function addPanels(). However i am unable to get whether that function is been called or not? Sec A works fine. Data is being inserted. However it is not performing addPanels(). Commented Apr 7, 2016 at 6:39
  • Did you tried $test_id = $this->db->insert_id();?? Commented Apr 7, 2016 at 11:38

1 Answer 1

1
//--Sec A--
$query = $this->db->insert('test',$insert_data);
$data['test_data'] = $query->result();

//The insert ID number when performing database inserts.
$test_Id = $this->db->insert_id();

// --Sec B--- code to get inserted row

$this->addPanels($panArr,$job_Id,$test_Id);//$test_Id is result of Sec B

echo json_encode($data);//Result of Sec A
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.