Hej everyone,
I'd like to know if there is a way to use $db->simple_select for a table without the mybb_ prefix.
Code looks like that at the moment:
$query = $db->simple_select("user_galleries", "id, name", "uid='1'", array("order_by" => 'name',
"order_dir" => 'DESC'));
$getit = $db->fetch_array($query);
Database table is user_galleries, MyBB wants to check mybb_user_galleries.
Any chance to avoid that without opening up another MySQL connection and doing a manual query?
Hmm... just wondering whether this will work or not. I guess it can't harm...
$old_prefix = $db->table_prefix;
$db->table_prefix = "new_table_prefix";
$query = $db->simple_select("user_galleries", "id, name", "uid='1'", array("order_by" => 'name',
"order_dir" => 'DESC'));
$getit = $db->fetch_array($query);
$db->table_prefix = $old_prefix;
Basically saves the normal prefix ($old_prefix), resets the prefix to whatever prefix you want it to, queries this table, then resets the prefix to the normal one to use everywhere else.
Might not work, but meh... let us know if it works!

You should use the $db->set_table_prefix and then once your done set it back. You could also just use $db->query directly
(2009-05-14, 03:48 PM)Ryan Gordon Wrote: [ -> ]You should use the $db->set_table_prefix and then once your done set it back.
That's the one I was thinking of...!

I wonder why you would go through all that when you could just use $db->query? What advantages does $db->simple_select have over $db->query?
Worked nicely, thank you!
(2009-05-14, 03:56 PM)skywalker2208 Wrote: [ -> ]I wonder why you would go through all that when you could just use $db->query? What advantages does $db->simple_select have over $db->query?
It will work with all DBMSes MyBB support. $db->query is proprietary to the DBMS you create it for.
Realisitically imho it would be better to just rename the table user_galleries to mybb_user_galleries. If this is a plugin then just make the adjustments to fix it to mybb standards.