1

i'm trying to insert multiple array to mysql, but getting error like this

Message: Cannot use object of type CI_DB_mysqli_result as array

Filename: operator_pt/Wsmahasiswa.php

Line Number: 357

here my code from controller

$database1 = $username1.'_'.$token.'_'.$temphmspt;
        $table1 = 'mahasiswa';
        $data1 = $this->db->query("select nm_pd from $database1");
        foreach($data1->result() as $key1){
        $filter1 = "nm_pd like '$key1->nm_pd'";
        $order1 = "nm_pd asc";
        $limit1 = 10;
        $offset1 = 0;
        $tampan1 = $proxy->GetRecordset($token, $table1, $filter1, $order1, $limit1, $offset1);
        $tampan1=$data1;
        $insert = $this->db->replace($database, $data1["result"]); //line 357

    }

here arrays example

Array
(
    [error_code] => 0
    [error_desc] => 
    [result] => Array
        (
            [0] => Array
                (
                    [id_pd] => cb5ab906-a9b5-49f2-95e9-0d30ce005bd9
                    [nm_pd] => BABABA

                )

            [1] => Array
                (
                    [id_pd] => f29128c2-27a0-4300-a4f5-842573e9e804
                    [nm_pd] => BIBIBI

                )

        )

)
Array
(
    [error_code] => 0
    [error_desc] => 
    [result] => Array
        (
            [0] => Array
                (
                    [id_pd] => 70500b08-a285-4e97-af0c-e8e43d2e5be6
                    [nm_pd] => BUBUBU

                )
3
  • You did not use result() like this $data1["result"] Commented Aug 22, 2016 at 8:00
  • do you mean like this ? $insert = $this->db->replace($database, $data1->result()); Commented Aug 22, 2016 at 8:01
  • What you want to do using $data1["result"]? Commented Aug 22, 2016 at 8:02

1 Answer 1

1

use $data1->result_array() instead of $data1->result() it will give you result in array

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.