10-12-2012, 02:33 AM
[eluser]Chris Davies[/eluser]
Hi all. I have been using Expression Engine for a year now. I have some basic PHP knowledge, but have never really used it as such.
I have a little bit of spare time, and have started looking into learning some to make a module for EE. I have managed to get quite far but have got myself a little confused and was hoping I could find some help here as I know EE is build on codeigniter.
Basically, I have a function that I want to query the database and find all 'follow_id' that match the user id that is entered in the tagdata.
The issue I have is I am only outputting one row, and I dont really understand how to output multiple rows...
Any advice would be wonderful, and thanks in advance for your patience with me
Hi all. I have been using Expression Engine for a year now. I have some basic PHP knowledge, but have never really used it as such.
I have a little bit of spare time, and have started looking into learning some to make a module for EE. I have managed to get quite far but have got myself a little confused and was hoping I could find some help here as I know EE is build on codeigniter.
Basically, I have a function that I want to query the database and find all 'follow_id' that match the user id that is entered in the tagdata.
The issue I have is I am only outputting one row, and I dont really understand how to output multiple rows...
Code:
public function summary() {
$tagdata = $this->EE->TMPL->tagdata;
$user_id = $this->EE->TMPL->fetch_param('user_id');
if( $user_id === FALSE ) {
return "";
}
$this->EE->db->select( "follow_id, COUNT(*) as total" );
$this->EE->db->where( "member_id", $user_id );
$this->EE->db->group_by( "follow_id" );
$query = $this->EE->db->get( "follow" );
if( $query->num_rows() == 0 ) {
$data = array(
"follow_id" => 0
);
} else {
$data = $query->row_array();
}
$variables = array();
$variables[] = $data;
return $this->EE->TMPL->parse_variables( $tagdata, $variables );
}
Any advice would be wonderful, and thanks in advance for your patience with me
