php - 插入mysql不完整值字段

标签 php mysql wordpress simplexml

我必须映射一个 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 表中

"PAVILLON TRADITIONNEL EDIFIE SUR SOUS SOL TOTAL !! Vaste salon s"

插入到'post_content'字段中,我还有两个'ANNONCE'节点。 是否是缓冲区溢出?

PS:'post_content'字段类型为longtext,我尝试在第一次迭代中退出循环,该字段已完全插入,我尝试增加memory_limit,将output_buffering更改为on。

最佳答案

这是utf8_decode的问题,我删除了它,问题解决了。

关于php - 插入mysql不完整值字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23884979/

相关文章:

php - 在 WooCommerce 快速订单预览中显示自定义字段

html - 在 Wordpress 中向带有子项的菜单项添加箭头

php - 如何使用 PHP 从 MYSQL 检索值到单选按钮?

Windows 上的 PHP_BINDIR 不正确?

php - 如果我使用 PHP,如何解决 c10k 问题?

php - 推特 REST API "Could not authenticate you."

PHP/MySQL 语句 - 从 2 个表中选择记录

mysql - Wordpress (4.2.7) - Apache 日志中的 HTTP GET/locate/503。 Apache 最终产生多个客户端来处理,然后 MySQL 就死掉了

python - 寻找一种更pythonic的方式来访问数据库

MySQL 最新的唯一用户聊天不起作用