Hi I've wrote a plugin it works but on deactivation it doesn't drop the plugin tables from db
this is the code

$sql = "DROP TABLE IF_EXISTS 'TABLENAME'";
                $wpdb->query($sql);
                //$e = $wpdb->query($sql);
                //die(var_dump($e));

and i call that function this way
register_deactivation_hook(FILE, 'deactivate');

if i uncomment to show message error it tells me on deativation

bool(false)

whiy doesn't it drop the table?? could you help me to fix it??
thank you

Recommended Answers

Check this code. Bit different than yours.

Jump to Post

All 3 Replies

Check this code. Bit different than yours.

with this code it worked!!

global $wpdb;   //required global declaration of WP variable

    $table_name = $wpdb->prefix.$table_name;

    $sql = "DROP TABLE ". $table_name;

    $wpdb->query($sql);

thank you!!

Nice. Mark it as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.