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?
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.
For me, I changed the field type from
VARCHAR
toTEXT
, but it still didn’t work. Finally, I found the table with collation ofutf8_general_ci
does not support emoji, so I removed all the emojis from the content then it works.