Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-13-2012, 08:34 AM   PM User | #1
CoolAsCarlito
Regular Coder

 
Join Date: Jun 2008
Posts: 679
Thanks: 114
Thanked 2 Times in 2 Posts
CoolAsCarlito can only hope to improve
Developing Multidiminsional Array

I'm trying to develop a resultset that appears like so:

Code:
[1] Title One name
     [champion] Jeff
     [contender1] kevin
     [contentder2] brian
     [contender3] will

[2] Title Two name
     [champion] Jeff
     [contender1] kevin
     [contentder2] brian
     [contender3] will

[3] Title Three name
     [champion] Jeff
     [contender1] kevin
     [contentder2] brian
     [contender3] will
I'm using the codeigniter's active record to develop this query and have this so far. To understand how my db structure looks this is what I am using.

To understand what the structure means is that the titles table defines the title id and the title name. The roster table defines the roster id and roster name. The title champions table has the table id which is the same as the title id from the titles table and champion id, contender1 id, contender2 id, contender3 id all represent the id of the roster table.

Code:
Titles Table
title_id
title_name

Titles Champions Table    
title_id
champion_id
contender1_id
contender2_id
contender3_id

Roster Table
roster_id
roster_name
This is what I have so far.

Code:
/**
     * Gets the listing of all title champions and contenders.
     * 
     * @return mixed (object/NULL) Object of title champions/contenders if query returned any data
     */
    public function get_title_champions()
    {
        $this->db->select($this->master_model->titles_table.'.title_name');
        $this->db->select($this->master_model->titles_table.'.title_id');
        $this->db->from($this->master_model->title_champions_table);
        $this->db->join($this->master_model->titles_table, $this->master_model->titles_table.'.title_id ='.$this->master_model->title_champions_table.'.title_id');
        $query = $this->db->get();
        return $query->result();
    }
Is there any additional ideas from anyone?

Last edited by CoolAsCarlito; 09-13-2012 at 06:26 PM..
CoolAsCarlito is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:51 PM.


Advertisement
Log in to turn off these ads.