MyBB Community Forums

Full Version: Is there any database method for fetch_row
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In quite a lot of my plugins for SMF and Joomla I use fetch row as this is the most efficient to use within my functions and classes. It appears the closest with myBB is fetch_array which is slightly different to what I need.

Any suggestions?

Basically I would use it as

function whatever($params) {

do some stuff
run a query

return mysql_fetch_row($query);
}
Why wouldn't you want it as an associative array?
Because it means a very large rewrite of code I had already written.

Also it seems to fail at the moment with the assoc array, even though the query is valid.

simple_query prefixes everything with mybb which doesn't work as I am pulling from a non-mybb table
Well there is no fetch_row function for MyBB, what isn't working with fetch_array()? Just use $db->query() instead then.
It's ok I will just do the assoc array. It's more out of laziness than anything else. but in the long run assoc array is cleaner
just use the $db->query() functionality. That returns a query object that you can pass to fetch row

function whatever($params) 
{
    global $mybb, $db;

    //do some stuff

    //run query
    $query = $db->query("write your SQL statement here");

    return mysql_fetch_row($query);
}
Thanks to you both.

I decided to go down the assoc array path. I was just being lazy really