I am trying to create function that archives a record. I have a list of records with each record having a dropdown with options delete, edit, archive. When archive is clicked Id like that record tp be moved to a new table and then that original record to be removed. Can I have an Insert and DElete run in the same query? If not how else can I achieve this? here is what I've currently got:
public function archiveCampaign($campaign_id) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "campaigns_archive` SELECT * WHERE campaign_id = '" . (int)$campaign_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "campaigns` WHERE campaign_id = '" . (int)$campaign_id . "'");
return $campaign_id;
}
mysqliand PDO where any user-supplied data is specified with a?or:nameindicator that’s later populated usingbind_paramorexecutedepending on which one you’re using. NEVER put$_POST,$_GETor any user data directly in your query.