Jump to content

Query in class stops when nesting another query


djones

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.