简体   繁体   English

$ wpdb-> insert not working,last_query不显示插入“SHOW FULL COLUMNS FROM”

[英]$wpdb->insert not working, last_query doesn't show insert “SHOW FULL COLUMNS FROM”

I run $wpdb->insert($table, $data) where data is an array with column_name => value and the insert is not working. 我运行$wpdb->insert($table, $data) ,其中data是一个column_name => value的数组,插入不起作用。 I tried $wpdb->last_query and something bizarre comes back: 我试过$wpdb->last_query并且奇怪的回来了:

SHOW FULL COLUMNS FROM `table_im_trying_to_insert`

Why is the last query not my insert? 为什么最后一个查询不是我的插入?

I found the problem. 我发现了这个问题。 Apparently with the new WP update if you try to insert into a VARCHAR column and the column length is less than what you are trying to insert it just won't work. 显然,如果您尝试插入VARCHAR列并且列长度小于您尝试插入的列,则新的WP更新将无法正常工作。 Prior to this update it will insert it but trim off the excess characters. 在此更新之前,它将插入它,但修剪掉多余的字符。

For me, I changed the field type from VARCHAR to TEXT , but it still didn't work. 对我来说,我将字段类型从VARCHAR更改为TEXT ,但它仍然无效。 Finally, I found the table with collation of utf8_general_ci does not support emoji, so I removed all the emojis from the content then it works. 最后,我发现utf8_general_ci排序表不支持表情符号,所以我从内容中删除了所有的表情符号,然后它就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM