Welcome Guest, Not a member yet? Register   Sign In
How to reset active record database query?
#4

[eluser]ZachWills[/eluser]
Hmm.. I do have a get in my loop. Here is the long explanation of what I am trying to accomplish:

I have comments in a table. I loop through each comment, and if one of those comments has replies to it (threaded comments) I create a new query to get all comments that reply to that comment. I have a query within another query... here is the code for my query that runs if there are replies... I stripped out all of the unnecessary specifics:

Code:
//if comment has reply
if( $row->has_replies == 1 ){

//query to get all of the post replies for this id
$this->CI->db->select('*')->from($this->_table_name)->where("which_reply", $row->id);
//actual command that gets it
$replyQuery = $this->CI->db->get();

//loop through each reply
foreach( $replyQuery->result() as $reply_row ){

  //create an array containing all the replies

}


//create a comment array and include the reply array if the comment has a reply


//append the comment array ^^ to my result

}

This function returns an array of all the comments and their replies.

I took out a ton of the specifics like the arrays themselves and what they contain because I want to get this as simple as possible so I don't waste your time if you are kind enough to take a look and help me out!


Messages In This Thread
How to reset active record database query? - by El Forum - 08-28-2012, 03:30 PM
How to reset active record database query? - by El Forum - 08-28-2012, 04:14 PM
How to reset active record database query? - by El Forum - 08-28-2012, 04:29 PM
How to reset active record database query? - by El Forum - 08-28-2012, 05:44 PM
How to reset active record database query? - by El Forum - 08-28-2012, 09:24 PM
How to reset active record database query? - by El Forum - 08-29-2012, 04:38 PM
How to reset active record database query? - by El Forum - 08-29-2012, 04:46 PM
How to reset active record database query? - by El Forum - 08-29-2012, 06:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB