我有这个数组。 p>
Array
(\ n [customer_id] =>数组
(
[customer_id] => 132
)
[file_name] =>数组
(
[0] => ht5appletv11.png
[1] => twitter-100px11.png
)
[file_path] =>数组
(
[0] => C:/xampp/htdocs/maintenance_assurance_sys/uploads/ht5appletv11.png
[1] => C:/xampp/htdocs/myproject/uploads/twitter-100px11.png
)
)
code> pre>
I 想要在CI中逐行插入这些数据到数据库中。但是每行的customer_id总是相同的。 file_name和file_path将更改。
例如: p>
我该怎么做? p>
blockquote>
+ --- -------------------------------------------------- ---------------- + \ N | customer_id | file_name | file_path |
| 132 | ht5appletv11.png | C:/ xampp / htodcs / ..... |
| 132 | twitter-100px11.png | C:/ xampp / htodcs / ..... |
+ ----------------------------------- ---------------------------------- +
代码> PRE>
< p>这是我的代码... p>
function insertUploadedFiles($ data)
{
foreach($ data as $ fileData)
{
$ datas [] = array(
'customer_id'=&gt; $ fileData ['customer_id'],
'file_name'=&gt; $ fileData ['file_name'],
'file_path'=&gt; $ fileData [' file_path']
);
}
$ this-&gt; db-&gt; insert_batch('t_customer_file_ref',$ datas);
}
code> pre>
但它只获得customer_id和file_name&amp; file_path显示如下错误。 p>
消息:未定义的索引:file_name p>
未定义的索引:file_path p>
< / blockquote>
div>