Domanda

Sto leggendo wordpress professionale. il loro codice di disinstallazione di un plugin è

//build our query to delete our custom table
$sql = "DROP TABLE " . $table_name . ";";

//execute the query deleting the table
$wpdb->query($sql);
require_once(ABSPATH .’wp-admin/includes/upgrade.php’);
dbDelta($sql);

la mia domanda è: perché correre dbDelta dopo $wpdb->query($sql);

È stato utile?

Soluzione

This is indeed bizarre. I think they first tried it with dbDelta, found it doesn't work with DROP queries, and went with a straight $wpdb query instead. They then just forgot to take out the dbDelta stuff. It appears dbDelta collects creation queries in $cqueries and insert queries in $iqueries, but silently ignores the rest. What a lovely function...

To be sure, you could ask this question on the book forum, hopefully the authors hang around there. Don't forget to mention you first asked it here, so we get some publicity!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top