我必须映射一个xml文件并将其节点插入到wordpress mysql表中。
$postTable = $wpdb->prefix . "posts";
$nouvelles = simplexml_load_file('annonces.xml');
foreach($nouvelles->ANNONCE as $annonce) {
$wpdb->insert(
$postTable, $post_arr =array(
'post_author' => 1,
'post_date' => current_time('mysql', 1) ,
'post_date_gmt'=>current_time('mysql', 1),
'post_content' =>utf8_decode($annonce->TEXTE),
'post_title'=>utf8_decode($annonce->TITRE),
'post_excerpt'=>'',
'post_status'=>'publish',
'comment_status'=>'closed',
'ping_status'=>'closed',
'post_password'=>'',
'post_name'=>str_replace(' ','-',utf8_decode($annonce->TITRE)),
'to_ping'=>'',
'pinged'=>'',
'post_modified'=>date("M d Y H:i:s"),
'post_modified_gmt'=>gmdate("M d Y H:i:s"),
'post_content_filtered'=>'',
'post_parent'=>0,
'guid'=>Site_url().'?post_type=property&p='.$idPost,
'menu_order'=>0,
'post_type'=>'property',
'post_mime_type'=>'',
'comment_count'=>''
));
}我的文本节点在annonce.xml中是这样的:
<TEXTE>PAVILLON TRADITIONNEL EDIFIE SUR SOUS SOL TOTAL !! Vaste salon sejour avec cheminee, grande cuisine amenagee et equipee donnant sur une veranda, 4 chambres, piscine chauffee, PRESTATIONS DE QUALITES</TEXTE>仅在mysql posts表中
“世园会传统沙龙!”
在'post_content'字段中插入,我还有两个'ANNONCE'节点。是缓冲区溢出吗?
PS:'post_content‘字段类型为长文本,我试图在第一次迭代中退出循环,字段被完全插入,我试图增加memory_limit,将output_buffering更改为on。
发布于 2014-05-27 18:26:39
这是utf8_decode的一个问题,我把它删除了,问题就解决了。
https://stackoverflow.com/questions/23884979
复制相似问题