insert multiple rows via a php array into mysql

后端 未结 12 1525
自闭症患者
自闭症患者 2020-11-21 22:35

I\'m passing a large dataset into a MySQL table via PHP using insert commands and I\'m wondering if its possible to insert approximately 1000 rows at a time via a query othe

12条回答
  •  失恋的感觉
    2020-11-21 23:28

    $query= array(); 
    foreach( $your_data as $row ) {
        $query[] = '("'.mysql_real_escape_string($row['text']).'", '.$row['category_id'].')';
    }
    mysql_query('INSERT INTO table (text, category) VALUES '.implode(',', $query));
    

提交回复
热议问题