MyBB Community Forums

Full Version: global $db
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I returned to plugin development here on mybb and I want to know if there is an alter table method available for us to use. As I don't see it in the wiki and I wish to add a row to the usergroup table.
The $db->insert_query($table, $array) method adds a row into the specified database table starting from an associative array. Example from newreply.php:

$imagearray = array(
    "imagehash" => $imagehash,
    "imagestring" => $randomstr,
    "dateline" => TIME_NOW
);
$db->insert_query("captcha", $imagearray);
I meant a new row like you have the gid, canviewthreads etc.
so in your example "imagehash" or "dateline".
Just build an array with the values you want and use the insert_query method.
Nevermind I found out that I can use my alter table statement with $db->write_query
$db->add_column is the one you search Wink
(2013-03-24, 09:55 AM)King Louis Wrote: [ -> ]$db->add_column is the one you search Wink

even more convenient thanks Smile
love to write clean code instead of full querys Smile

(2013-03-24, 10:00 AM)Shade Wrote: [ -> ]I understood what you meant: if there's an "ALTER TABLE" method to edit or add a column, not a row. You know, the meaning of your first post was quite difficult to understand, and yeah, you have to write down the query with the write_query method or use the add_column one.

Hi see the post of king louis Smile
Also no problem sorry I haven't made it clear from the start..
I understood now what you meant: if there's an "ALTER TABLE" method to edit or add a column, not a row. You know, the meaning of your first post was quite difficult to understand, and yeah, you have to write down the query with the write_query method or use the add_column one.
Example:

$db->query("ALTER TABLE ".TABLE_PREFIX."users ADD your_variable TEXT NOT NULL");