$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. I tried $wpdb->last_query and something bizarre comes back:

SHOW FULL COLUMNS FROM `table_im_trying_to_insert`

Why is the last query not my insert?

Related posts

Leave a Reply

2 comments

  1. 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. Prior to this update it will insert it but trim off the excess characters.

  2. For me, I changed the field type from VARCHAR to TEXT, but it still didn’t work. 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.