Welcome Guest, Not a member yet? Register   Sign In
Joins as array
#1

[eluser]skribe[/eluser]
Sorry my brain has vacated the premises and so I'm having difficulties attempting to loop through an array to produce a join. ie
Code:
$joins = array(
                   array('contact', 'contact.id = person.id', 'left'),
                   array('info', 'info.id = person.id','left)
                             );

                foreach($joins as $join){
                   foreach($join as $item) {                    
                        something
                   }
                    $this->db->join(something);
                }

Any suggestions?
#2

[eluser]Techno Heart[/eluser]
Are you trying to pass the join variable in to a query ? what you exactly looking for ??be clear..
#3

[eluser]Atharva[/eluser]
It is sometimes better to use simple sql queries(i.e w/o Active Record) rather than making things complicated like you are doing.
#4

[eluser]skribe[/eluser]
I'm actually adapting this crud model which doesn't have a multi-table capability.
#5

[eluser]Atharva[/eluser]
Code:
$joins = array(
                   array('contact', 'contact.id = person.id', 'left'),
                   array('info', 'info.id = person.id','left')
                             );

                foreach($joins as $join){
                   $this->db->join($join[0], $join[1], $join[2]);
                    
                }

Is this what you are looking for?
#6

[eluser]skribe[/eluser]
That's exactly what I was after. Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB