WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am reading professional wordpress. their code for uninstalling a plugin is

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

//execute the query deleting the table
require_once(ABSPATH .’wp-admin/includes/upgrade.php’);

my question is why run dbDelta after $wpdb->query($sql);

share|improve this question
up vote 3 down vote accepted

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!

share|improve this answer
thanks i will link back here :) – Jiew Meng Sep 12 '10 at 2:05
I noticed this too. I see you didn't get an answer on the book forum either :-( – codecowboy Feb 4 '11 at 15:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.