db_query('SELECT nid FROM uc_products'); doesn't give any results! Why? There's a really simple query related to the enabled and working Ubercart, where the task is to get all the nids from uc_products table, which simply doesn't give any results:

$query = 'SELECT nid FROM uc_products';
$result = db_query($query);
dsm('===================================================');
dsm($query);
while ($nid = db_result($result)) {
    dsm('$nid: '.$nid);
}


BUT when I run the very same query in the same database in phpMyAdmin, it works, and it gives me ALL the correct results (I have 8 products now).



BUT the following queries work correctly, and give me all the expected results (the first is the strangest, because vid field is of the same type, but only has another name):

$query = 'SELECT vid FROM uc_products';
$result = db_query($query);
dsm('===================================================');
dsm($query);
while ($vid = db_result($result)) {
    dsm('$vid: '.$vid);
}

$query = 'SELECT * FROM uc_products';
$result = db_query($query);
dsm('===================================================');
dsm($query);
while ($row = db_fetch_object($result)) {
    dsm('$row-&gt;nid: '.$row-&gt;nid);
}

$query = 'SELECT nid FROM node';
$result = db_query($query);
dsm('===================================================');
dsm($query);
while ($nid = db_result($result)) {
    dsm('$nid: '.$nid);
}


Here's a screenshot of the test results:



As you can see, the first two queries don't return any results, while the others work correctly.
This is a really strange problem. I didn't modify the core modules, so I don't understand the situation. It doesn't matter whether I run it on localhost or my ongoing public server, the result is the same. This means that uc_order_condition_has_products_form() in Conditional Actions menu doesn't work correctly either. I've never ever met such problems in Drupal. 

Does anyone have a clue where I should start debugging?
I think it is likely because your first result is a "0" and php will evaluate that as a False, which stops your while loop from running.