djones Posted March 17, 2009 Share Posted March 17, 2009 For some reason the nested query is stopping the parent from completing. What am I over looking? Of course this is not the actual query but an example that fails too. public function list_stuff(){ $sql = "SELECT id FROM project"; $this->query($sql); while ($row = $this->rs->fetch_assoc()) { echo $row['id'].'<br />'; echo $this->pull_more_stuff($row['id']).'<br />'; } } public function pull_more_stuff($id){ $sql = "SELECT project_name FROM project WHERE id = '".$id."'"; $this->query($sql); $row = $this->rs->fetch_row(); return $row[0]; } If I comment out echo $this->pull_more_stuff($row['id']).'<br />'; the parent query will complete and I will get the results (project ids): 1 2 3 When I leave that line in I get: 1 Project Name Link to comment https://forums.phpfreaks.com/topic/149892-query-in-class-stops-when-nesting-another-query/ Share on other sites More sharing options...
djones Posted March 18, 2009 Author Share Posted March 18, 2009 This is MySQL 5 btw Link to comment https://forums.phpfreaks.com/topic/149892-query-in-class-stops-when-nesting-another-query/#findComment-787285 Share on other sites More sharing options...
trq Posted March 18, 2009 Share Posted March 18, 2009 Id suggest looking into joins rather than pursuing your line of logic. Link to comment https://forums.phpfreaks.com/topic/149892-query-in-class-stops-when-nesting-another-query/#findComment-787287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.