using a query result in another query binding? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: using a query result in another query binding? (/showthread.php?tid=77886) |
using a query result in another query binding? - richb201 - 10-31-2020 I've done a sql query and I get a structure called query2. I'd like to use the item (coding) to search a different table. Code: $query2 = {CI_DB_mysqli_result} [8] But when I do the following I get an error "Object of class stdClass could not be converted to string". Can I cast it to a string? I'd like $item to be "coding". Code: $item=$query2->result(); RE: using a query result in another query binding? - richb201 - 10-31-2020 Solved! I used this: foreach ($query2->result_array() as $row2) { //check to see if item is qualified and if yes, then add to qualified, not_qualified, or notApp count $item=$row2['item']; $sql3 = "SELECT a.qualified FROM standard_activities sa, relation r, activity a WHERE sa.activity=? AND sa.id=a.id"; $query3=$this->db->query($sql3, array($item)); } |