i am working on a plugin that includes table in database that holds information from the different posts. right now i use $wpdb->replace()
, so whenever a post is being created or updated it is also create a new row in my table or update one that is already exist.
my questions are:
- is
replace()
already sanitizing the values before insert them into my table or do i have to useprepare()
before i use replace? - is it ok to use replace so i can cover both cases of "insert" for new post and "upadte" if updating post or should i use
update()
if exist else "insert" if not. i know that replace is slower when it comes to performance but maybe it is ok when not being used very often (well, only when creating and updating posts)?