0
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.

satish kilari
  • 746
  • 4
  • 21

4 Answers4

3

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

Drudge Rajen
  • 7,584
  • 4
  • 23
  • 43
3

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;
Community
  • 1
  • 1
Nabin Kunwar
  • 1,965
  • 14
  • 29
0

$query is being initialized to a string and then is accessed for an object. This is inconsistent for sure.

rpy
  • 3,953
  • 2
  • 20
  • 31
0

$query is a string, I guess you should use $result->result_array().

Mark van Herpen
  • 347
  • 3
  • 12