Good day.

I make a request to the database as follows:

$db->query("SELECT * FROM `" . PREFIX . "_urls` WHERE zakaz_id='$zakaz_id' "); while ( $row = $db->get_row() ) { } 

But in the cycle I need to make a couple more requests (already for a specific position) I do this:

  $db->query("SELECT * FROM `" . PREFIX . "_zakaz` WHERE id='$zakaz_id' "); while ( $row = $db->get_row() ) { $db->query("SELECT * FROM `" . PREFIX . "_urls` WHERE zakaz_id='$row[id]' "); $poz = $db->num_rows(); } 

But after the internal request, the next cycle of the main cycle already gives out something wrong (well, I understand why)

Tell me, who is familiar with the architecture of the DLE, can there be an opportunity for requests to specify an identifier somehow?

    1 answer 1

    The MySQL class in DLE uses the default database pointer. That is, every time you query the database, the pointer changes. So do this:

     $rez1=$db->query("SELECT * FROM `" . PREFIX . "_zakaz` WHERE id='$zakaz_id' "); while ( $row = $db->get_row($rez1) ) { $rez2=$db->query("SELECT * FROM `" . PREFIX . "_urls` WHERE zakaz_id='$row[id]'"); $poz = $db->num_rows($rez2); } 

    But this is desirable not to do. You can do with a single query, as shown by @SilverIce