2014-07-25 31 views
0

我有一個〜44k行數據庫,我希望每一行都是一個帖子,所以我可以將它們顯示到wordpress中並輕鬆管理它們。我執行了下面的代碼,它只添加了〜21k行到wp_posts並停止了。我需要一種方法將整個數據庫移動到wp_posts。有任何想法嗎?從另一個數據庫向WP db添加帖子

$results=$wpdb->get_results("SELECT * FROM `wp_doctors` ORDER BY `nume`"); 
foreach($results as $r){ 
// Create post object 
$my_post = array(
'post_title' => $r->nume, 
'post_content' => $r->spec.'</br>'.$r->institutie.'</br>'.$r->judet.'</br>'.$r->localitate, 
'post_status' => 'publish', 
'post_author' => 1, 
'post_category' => array(8,39) 
); 

// Insert the post into the database and return the post id 
    $post_id=wp_insert_post($my_post, $wp_error); 
} 
+0

可能這是由於的max_execution_time,請在php.ini中的max_execution_time和增加它與嘗試.. –

回答

0

我也認爲這是死亡腳本的運行時描述。

嘗試:ini_set('max_execution_time', 0);(我認爲這不會對共享主機工作)

您也可以使用現有的解決方案就像Big Dump它是由處理大量的數據。

+0

它不工作:( – user3776900

+0

你在共享主機? – kevdev

+0

是的,但是這max_exec_time被管理員改變我的託管解決方案 – user3776900

相關問題