Reputation: 728
public function insrt_into_aprlog($id)
{
$query = 'insert into log_indent_apval (select id,indent_req_id,item_id,req_qty,approval_qty,approval_status,prod_categry,prod_type from tra_inent_rq_itm_dt where id ='.$id.')';
$result = $this->db->query($query);
$resultarr = $result->result_array();
}
my controller line:
$this->outpatient_model->insrt_into_aprlog($indent_id);
error : Call to a member function result_array() on a non-object
even i tried using in codeigniter model insert_batch();
still no use.
Upvotes: 0
Views: 48
Reputation: 1996
Reference Look into your query.
INSERT INTO table1 ( column1, column2, someInt, someVarChar )
SELECT table2.column1, table2.column2, 8, 'some string etc.'
FROM table2
WHERE table2.ID = 7;
Upvotes: 3
Reputation: 7987
result_array() is used to generate query result . You are trying to insert data in your table i guess, so you shouldn't use that . Try below code.
public function insrt_into_aprlog($id)
{
$query = 'insert into log_indent_apval (select id,indent_req_id,item_id,req_qty,approval_qty,approval_status,prod_categry,prod_type from tra_inent_rq_itm_dt where id ='.$id.')';
return $this->db->query($query);
}
Please visit this
Upvotes: 3
Reputation: 347
$query
is a string, I guess you should use $result->result_array()
.
Upvotes: 0
Reputation: 4013
$query
is being initialized to a string and then is accessed for an object. This is inconsistent for sure.
Upvotes: 0