我想通过codeigniter上的数组数据更新数据库表中的值,但我有输出错误。如何解决?
PHP:
$mainpage = $this - > input - > post('mainpage');
$data2 = array();
foreach($mainpage as $idx = > $name) {
$data2[] = array(
'mainpage' = > $name[0],
'subpage' = > json_encode($this - > input - > post('subpage')[$idx]),
'service' = > json_encode($this - > input - > post('tdadeps')[$idx]),
'id_relation' = > $id_relation, );
$this - > db - > where('id_relation', $id_relation);
$data22 = $this - > db - > update('access_level', $data2);
}
输出错误:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: mysql/mysql_driver.php
Line Number: 612
A Database Error Occurred
Error Number: 1054
Unknown column '0' in 'field list'
UPDATE `access_level` SET `0` = Array WHERE `id_relation` = '2'
Filename: W:\system\database\DB_driver.php
Line Number: 330