Tuesday 14 April 2015

Multiple Joins using Custom Php & Active Records



  • Join Multiple Table Using Codeigniter Active Records.

  • Codeigniter Active Records:
    $this->db->select('*');  
    $this->db->from('TableA AS A');// I use aliasing make things joins easier  
    $this->db->join('TableC AS C', 'A.ID = C.TableAId', 'INNER');  
    $this->db->join('TableB AS B', 'B.ID = C.TableBId', 'INNER');  
    $result = $this->db->get();  
    
    Custome MySql Query
    SELECT *  
    FROM TableA AS A  
        INNER JOIN TableC AS C  
        ON C.TableAId = A.ID  
        INNER JOIN TableB AS B  
        ON B.ID = C.ID  
    

    Your can also write Mysql Query Under Active Records Method:

    $this->db->query();
    $this->db->query("SELECT *   FROM TableA AS A  
        INNER JOIN TableC AS C  
        ON C.TableAId = A.ID  
        INNER JOIN TableB AS B  
        ON B.ID = C.ID");  
    


    $this->db->query(); Utilizes mysql_query();
    Share this post
    • Share to Facebook
    • Share to Twitter
    • Share to Google+
    • Share to Stumble Upon
    • Share to Evernote
    • Share to Blogger
    • Share to Email
    • Share to Yahoo Messenger
    • More...

    0 comments

    :) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

     
    Posts RSSComments RSSBack to top
    © 2015 Eraneed ∙ Designed by Templates Crowd
    Released under Creative Commons 3.0 CC BY-NC 3.0