I want to insert about 10000 new rows to an existing table which contain 10000 rows already. I need to get the insert id for the query and to use that id in another function inside the loop as in the code below.
foreach($values as $val){
$sql = "INSERT INTO wp_posts (`post_author`, `post_date`, `post_content`, `post_title`, `post_excerpt`, `post_status`,`post_modified`,`post_type`)
VALUES('".$val[author]."',NOW(),'".$val[content]."','".$val[title]."','".$val[excerpt]."','published',NOW(),'post')";
$result = mysql_query($sql);
$insertid = mysql_insert_id();
add_post_meta($insertid, $val[metakey], $val[metaval], true );
}
I am fetching the values for $values array from a CSV file. As of now, I can insert only 20 new rows per 3 minutes. Is there anyway to speed up this insertion?