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 Quote 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 Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.