News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Problem: Unable to get all results, db_query returning only one result

Started by anir, July 16, 2016, 06:38:26 AM

Previous topic - Next topic

anir

$request = $smcFunc['db_query']('', '
                SELECT `id_group`,`group_name`
                FROM {db_prefix}membergroups'
            );
$result = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
print_r($result);


That is my code, I am running a query but it is returning only 1 result. I have not put any limit so it should return all results.

Using smf 2.0.11, I want to get all groups, I have included ssi.php.
SMF is the best forum I have ever used, efficient support system has always helped me and the very nice documentation too!

Arantor

You only run db_fetch_assoc once, you need to keep running it to get each row, it returns false when there are no more rows.
Holder of controversial views, all of which my own.


anir

Oh silly me, haven't used non-mvc frameworks for a long time now so I forgot, it worked thanks a lot.
SMF is the best forum I have ever used, efficient support system has always helped me and the very nice documentation too!

live627

Yeah SMF has no equivalent to fetchAll() et al. These database functions are just a (very) thin wrapper around mysqli_* or pg_* functions.

Advertisement: