php+mysql: insert a php array into mysql

后端 未结 4 602
时光取名叫无心
时光取名叫无心 2020-12-22 07:54

I have an array with 30000 plus entries that need to go into a MySQL table.

What is the best practice? From here? Lets say [0], [1] and [2] in the database would be

4条回答
  •  庸人自扰
    2020-12-22 08:17

    $statement = "INSERT INTO table (title, type, customer) VALUES ";
    foreach( $data as $row) {
       $statement .= ' ("' . implode($row, '","') . '")';
    }
    

    UPDATE: Changed explode to implode (I always get those confused).

提交回复
热议问题