Topic: Drop database doesn't work, why?

Running the uninstall from my plugin doesn't drop the table, no error/success Flash either:

<?php
$PDO = Record::getConnection();

if($PDO->exec("DROP TABLE IF EXISTS ".TABLE_PREFIX."foo") === false) {
    Flash::set('error', __('Unable to drop table :tablename', array(':tablename' => TABLE_PREFIX.'foo')));
} else {
    Flash::set('success', __('Plugin is succesfully uninstalled!'));
}

Any idea why?

Re: Drop database doesn't work, why?

Try this:

$PDO = Record::getConnection();

if($PDO->exec('DROP TABLE IF EXISTS '.TABLE_PREFIX.'foo') === false) {
    Flash::set('error', __('Unable to drop table :tablename', array(':tablename' => TABLE_PREFIX.'foo')));
}
else {
Flash::set('success', __('Plugin is succesfully uninstalled!'));
}

You double quotes within mysql statement so I assume that that is the reason why it won't work.

Wolf CMS Paper Guy
Wolf CMS related blog / journal at Project 79 | Wolf CMS Docs

Re: Drop database doesn't work, why?

jackie wrote:

Try this:
You double quotes within mysql statement so I assume that that is the reason why it won't work.

Hi Jackie,

i've tried the single quotes version but it still doesn't work.
When in phpMyAdmin I can drop the table using this SQL statement:

DROP TABLE IF EXISTS foo

So that to me does seem to rule out permission problems.
Got some more idea's?

Re: Drop database doesn't work, why?

No more ideas sad I've just tried that code and it un-installed and deleted table from db without any problem (that is on ubuntu server, PHP 5.3.5, Mysql 5.1.54).

Wolf CMS Paper Guy
Wolf CMS related blog / journal at Project 79 | Wolf CMS Docs

Re: Drop database doesn't work, why?

Just tried it on a different host, they run Php 5.2.17 and MySQL 5.1.57
and it still doesn't drop the database.
Frustrating sad

Re: Drop database doesn't work, why?

I have the same in Wolf 0.7.5 & PHP 5.3.5.

I don't believe there is an error in your code, I believe the error is in the 'Uninstall' button in the plugins list so the 'uninstall.php' script did not run at all.

You can test this of course by putting some other code in your uninstall.php file.

Visitors plugin on the forum | repository
SEO plugin on the forum | repository

Re: Drop database doesn't work, why?

I beg the difference. I have tried install/enable and uninstall and they work as it should. Maybe some php version specific problem!?!?

Wolf CMS Paper Guy
Wolf CMS related blog / journal at Project 79 | Wolf CMS Docs