Query in Query problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello All,

We many times encounter the situations of having Queries inside loop of
another query. Many times we can solve the issue by query joins but there
will be some situations where we cannot do it.

For Example:

function Change($id){

        $qry_reg = "SELECT registrationID FROM registration  WHERE event_id
= '$id'";
        $res_reg =& $this->mdb2->query($qry_reg);

        while ($row_reg = $res_reg->fetchRow()) {
            $userid = $row_reg['registrationid'];
            $sql_insert = "INSERT
               INTO
               run
               (command, event_id, created, user_id, runtime)
               VALUES
               ('topic_change', '".$id."', NOW(), '".$userid."', NOW())";
                $res_insert =&  $this->mdb2->query($sql_insert);

        }
    }

How can we deal with this kind of stuff? My concern is to just use the query
once instead on burdening the Mysql Server with so many queries.... This is
just one case. How do we actually deal with these kind of situations?

Thanks

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux