Hello
given that reading the guide the given Model should manage one table, I'm wondering if my question is acceptable
or if my approach is wrong
So first of all thank you for hinting about the right approach
Aiming to have Models for the DB queries operations,
My question is related to the fact 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?
Is this possible in the same Model? If yes, how to?
Or should I anyway have three models or Entity class and then manage the access to the three tables at Controller level?
Thank you for pointing out the right approach