Recommended WP Core INSERT Query Method
-
My data importer accepts any .csv file. So I cannot predict the number of columns or their titles/headers.
WP core insert() does not escape single quotes despite everything I read indicating that using $wpdb->insert() prepares the INSERT. The codex states the following but the only way to avoid a MySQL error is to escape individual values…
(array) Data to insert (in column => value pairs). Both $data columns and $data values should be “raw” (neither should be SQL escaped).
What would be the recommended approach to using prepare() and possibly PDO within the WordPress environment? Keeping in mind I would need to add a number of placeholders based on the users .csv file.
I’m considering eval() to build the prepare() line but surely that is not safe?
mysql_real_escape_string() allows the import, escaping single quote, however it is depreciated.
Thanks community.
The topic ‘Recommended WP Core INSERT Query Method’ is closed to new replies.