$wpdb->UPDATE未更新,数据的var_ump正确

时间:2016-06-28 作者:Hermants

我对下面的$wpdb->更新有问题。var\\u dump数据正确,但更新没有将数据保存到表的记录中。表名为wp\\u rdp\\u media\\u organizations。唯一字段是media\\u org\\u id。

你们有人知道我做错了什么吗?提前谢谢。

if(isset($_POST[\'update_media_org\'])){
//var_dump($_POST);
extract($_POST);

$media_org_id = \'\';
$wpdb->update( 
    $wpdb->prefix.\'rdp_media_organisations\', 
    array( 
        \'media_org_id\'      => $media_org_id,
        \'company_name\'      => $company_name,
        \'gender\'            => $gender,
        \'first_name\'        => $first_name,
        \'last_name\'         => $last_name,
        \'street_address\'    => $street_address,
        \'zipcode\'           => $zipcode,
        \'visit_addres\'      => $visit_addres,   
        \'visit_zipcode\'     => $visit_zipcode,          
        \'city\'              => $city,
        \'country\'           => $country,
        \'email_address\'     => $email_address,
        \'telephone\'         => $telephone,
        \'mobile_nr\'         => $mobile_nr,
        \'status\'            => $status,         
        \'comments\'          => $comments,
        \'last_updated\'      => date("Y-m-d H:i:s")          
    ), 
    array( \'media_org_id\' => $row_id ), 
    array( 
        \'%d\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%s\' ,
        \'%d\' ,
        \'%s\' ,      
        \'%s\'            
    ) , 
    array( \'%d\' ) 
);
$msg = \'Record is updated sucessfully.\';
}



array(17) { ["row_id"]=> string(2) "45" ["company_name"]=> string(22) "Media Bureau Lekker bv" ["gender"]=> string(4) "Male" ["first_name"]=> string(3) "Jan" ["last_name"]=> string(8) "de Vries" ["street_address"]=> string(12) "Postadres 12" ["zipcode"]=> string(6) "8923FG" ["visit_addres"]=> string(13) "Bezoekadres 4" ["visit_zipcode"]=> string(6) "8999DW" ["city"]=> string(10) "Lekkerveen" ["country"]=> string(9) "Nederland" ["email_address"]=> string(20) "[email protected]" ["telephone"]=> string(12) "435635464536" ["mobile_nr"]=> string(14) "33634565463456" ["status"]=> string(1) "0" ["comments"]=> string(74) "Nieuw beureau oppassen met credit geven. Betalen binnen 5 dagen is vereist" ["update_media_org"]=> string(10) "Update Now" } 

1 个回复
最合适的回答,由SO网友:Hermants 整理而成

当以下变量为空时,

$media_org_id = \'\';
它会导致一个空的record_id.

相关推荐

Huge wp_options table

我有一个WP网站的问题。由于没有更多可用磁盘空间,网站崩溃。搜索时,我检测到wp\\U选项表大小为12GB,但大约只有1100行:有什么想法吗?提前感谢[UPDATE 1]如果我导出wp\\U选项表,拖放并导入,大小将减少到9,7mb:我没有机会用优化表OPTIMIZE TABLE wp_options 但如果再发生的话我会试试的[UPDATE 2]问题仍然存在。我试着OPTIMIZE TABLE wp_options;无结果: