Welcome Guest, Not a member yet? Register   Sign In
Mysql Queries - Best Tips
#1

[eluser]cristian_c[/eluser]
So I have multiple tables that I need to pull the data from. This is how I have been doing it but I not confident that this is the best way to do this. here is some code

Code:
function getBlogs()
    {
        $query = $this->db->get('blogs');
        $result = $query->result_array();
        foreach($result as $i => $post){
            $result[$i]['blogger'] = $this->getBlogger($post['author_id']);
            $result[$i]['categories'] = $this->getCategory($post['cat_id']);
        }
        return $result;
    }
    function getBlogger($author_id)
    {
         $this->db->where('id',$id);
         $query = $this->db->get('accounts');
         return $query->row_array();
    }
    function getCategory($cat_id)
    {
         $this->db->where('post_id',$cat_id);
         $query = $this->db->get('posts_categories');
         return $query->result_array();
    }


Messages In This Thread
Mysql Queries - Best Tips - by El Forum - 06-17-2008, 02:17 PM
Mysql Queries - Best Tips - by El Forum - 06-17-2008, 06:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB