a method for inserting multiple rows with in a safer and faster way
Switch branches/tags
Nothing to show
Clone or download
mirzazeyrek Merge pull request #5 from entr0cks/master
Fixed "%d" usage with floats and added uniform indentation.
%d turns float into integer, removing information.
Changed the placeholder logic in the end of $row_array's foreach.
Latest commit 94d08df May 6, 2017
Failed to load latest commit information.
README.md removed redundant loop. styling improvements. Sep 15, 2016
wp_insert_rows.php Update wp_insert_rows.php May 6, 2017


Wordpress Multiple Insert

A Wordpress method for inserting or updating multiple rows in a safer and faster way

usage example for insert:

       $insert_arrays = array();
       $time = current_time( 'mysql' );
       $insert_arrays[0] = array(
       'type' => "multiple_row_insert",
       'status' => 1,
       'name'=>"gordon freeman",
       'added_date' => $time,
       'last_update' => $time);
       $insert_arrays[1] = array(
       'type' => "multiple_row_insert",
       'status' => 2,
       'name'=>"captain dance",
       'added_date' => $time,
       'last_update' => $time);
       $insert_arrays[2] = array(
       'type' => "multiple_row_insert",
       'status' => 3,
       'name'=>"doc. emmet l. brown",
       'added_date' => $time,
       'last_update' => $time);

usage example for update:

   	wp_insert_rows($insert_arrays, $wpdb->tablename, true, "primary_column");

source : http://stackoverflow.com/a/12374838/1194797