MyBB Community Forums

Full Version: Plugin not recognising table existing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey all,

I'm missing something really small here, I'm not sure what. This is my first time making a plugin so bear with me Toungue

In my is_installed function, I have the following code: 
    global $db;
    if($db->table_exists("flts_paypal")) {
        echo 'True';
        return true;
    }
    else {
        echo 'false';
        return false;
    }

(echos are for testing)

And in my install I have this code (relating to the table): 
    $sql = "CREATE TABLE flts_paypal(#####)";
    
    $db->write_query($sql);

(Hashes in place of SQL). The table creates normally in the database, however, my is_installed returns false every time, meaning you don't get the option to deactivate or uninstall the plugin. 

Any thoughts?

Thanks,
Flinty
table_exists(), as well as other database functions, uses the configured table prefix (mybb_ by default) - generally, plugins should use the same one as the MyBB installation, so you can prepend the TABLE_PREFIX constant to installed table names to use these functions.
Right, I think I get you.

So table name should be TABLE_PREFIX . “paypal”; ?

Update:

So I updated it to create a table using the prefix constant, but it's still returning false after creation.

Edit, fixed it. Thanks @Devilshakerz