Welcome Guest, Not a member yet? Register   Sign In
MVC confusion redux
#10

[eluser]Maglok[/eluser]
Ooh, that's a neat trick.

Code:
SELECT `n`.*, `a`.`voornaam` as a_voornaam, `a`.`tussenvoegsel` as a_tussenvoegsel,
`a`.`achternaam` as a_achternaam, `e`.`voornaam` as e_voornaam,
`e`.`tussenvoegsel` as e_tussenvoegsel, `e`.`achternaam` as e_achternaam
FROM (`nieuws` n)
LEFT JOIN `personen` a ON `n`.`auteur_id` = `a`.`id`
LEFT JOIN `personen` e ON `n`.`aanpasser_id` = `e`.`id`
ORDER BY `n`.`date_created` desc

Code:
function get_all() {
         $this->db->select('n.*, a.voornaam as a_voornaam, a.tussenvoegsel as
a_tussenvoegsel, a.achternaam as a_achternaam, e.voornaam as e_voornaam,
e.tussenvoegsel as e_tussenvoegsel, e.achternaam as e_achternaam');
        $this->db->from('nieuws n');
        $this->db->join('personen a','n.auteur_id = a.id', 'left');
        $this->db->join('personen e','n.aanpasser_id = e.id', 'left');
        $this->db->order_by('n.date_created', 'desc');

        return $this->db->get();
    }

EDIT: Implemented it, and it works now, see above. Thanks for the help. I am now going to look into the get_all, get business.


Messages In This Thread
MVC confusion redux - by El Forum - 11-26-2009, 09:15 AM
MVC confusion redux - by El Forum - 11-26-2009, 09:21 AM
MVC confusion redux - by El Forum - 11-26-2009, 09:27 AM
MVC confusion redux - by El Forum - 11-26-2009, 10:56 AM
MVC confusion redux - by El Forum - 11-27-2009, 04:36 AM
MVC confusion redux - by El Forum - 11-27-2009, 04:56 AM
MVC confusion redux - by El Forum - 11-27-2009, 05:20 AM
MVC confusion redux - by El Forum - 11-27-2009, 05:53 AM
MVC confusion redux - by El Forum - 11-27-2009, 06:00 AM
MVC confusion redux - by El Forum - 11-27-2009, 06:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB