我试图将多个数组插入mysql,但是收到这样的错误
消息:无法使用CI_DB_mysqli_result类型的对象作为数组
文件名:operator_pt / Wsmahasiswa.php
行号:357
这里是我来自控制器的代码
$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
}
这里是数组示例
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
)
答案 0 :(得分:1)
使用$data1->result_array()
代替$data1->result()
,它会为您提供数组