用数组多次更新mySQL数据库?

时间:2015-08-21 08:32:08

标签: php arrays database laravel

我在Laravel上使用php。我想用这个数组更新我的数据库,当我执行此查询以更新我的数据库时,此数据库更新了2次。

它就像数组1,数组1然后数组,2数组2 ...我想要的只是数组1然后是数组2.所以我该如何解决这个问题?感谢。

$chcount = count($kfamily_profile['chname'])-1;

for($x=0;$x<=$chcount;$x++)
{

    $childinput[$x] = array(
        'child_name'            => $kfamily_profile['chname'][$x],
        'gender'                => $kfamily_profile['chgender'][$x],
        'child_pob'             => $kfamily_profile['chpob'][$x],
        'child_dob'             => $kfamily_profile['chdob'][$x]
    );

    DB::table('kids')
                    ->where('fathers_name','=', $fname)
                    ->where('mothers_name','=', $mname)
                    ->orderBy('child_dob','ASC')
                    ->update($childinput[$x]);

}

0 个答案:

没有答案