Welcome Guest, Not a member yet? Register   Sign In
Can I have 2 tables in codeigniter 4 model?
#6

Hello
I landed on this topic because basically I'd like to use Models for DB methods and the relative queries

Well I have a complex query with some joins which require the access to two more tables in the same DB

E.G.
db name : tickets

Model is TicketModel which is set to work with 'ticket' table

but in the TicketModel I need to write a method more or less like


PHP Code:
    public function getTicketList()
    {
        return $this->select('ticket.ticket_id, ticket.subject, dept.name AS department, ticket.name AS user, ticket.custom_text, ticket.lastpost, post.message AS last_message')
            ->join('dept''dept.dept_id = ticket.dept_id')
            ->join('post''post.id = ticket.lastpost')
            ->groupBy('ticket.ticket_id')
            ->orderBy('ticket.ticket_id''ASC');
    


well, how do I "enable" the 'dept' and 'post' tables?

Thank you
Reply


Messages In This Thread
RE: Can I have 2 tables in codeigniter 4 model? - by Corsari - 05-17-2023, 01:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB