This is one way to do this. This worked for me:
1) just do two separate MySql queries. The first inserts the post values ββinto the wp_posts table. You must insert in all columns except the "guid" column, insert some kind of placeholder, for example, "0".
2) the second request is executed immediately after the first, and here you can call the LAST_INSERT_ID () function to get the true last insert identifier of the previous request. This second request updates the "guid" field with the correct identification number.
You can insert this into a loop to bulk insert WP entries from a csv file, for example.
You must do this when the site is down or blocked at first, so no other request request is between the form somewhere else.
Example: first query (sorry to format the column, but it's easier to debug):
mysql_query("INSERT INTO wp_posts( ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count ) VALUES ( 'null', '1', '$timestmp', '$timestmp', '$content', '$posttitle', '', 'publish', 'open', 'open', '', '$postname', '', '', '$timestmp', '$timestmp', '', '0', '$uiai', '0', 'post', '', '0' )") or die(mysql_error());
Second request:
$uid = mysql_insert_id(); $uiai = 'http://yoursite.net/wordpress/?post_type=post&p='.$uid; mysql_query("UPDATE wp_posts SET guid = '$uiai' WHERE ID = '$uid'");
... also, when you iterate over a lot of inserts, sometimes it can maximize the maximum allowable runtime for a PHP script, and loading is interrupted. This helps to use set_time_limit (0); throughout the script, so the maximum allowed time counter will be reset.
... hope this helps :)