Hi,
OsTicket v1.15 user here, I am trying to use understand the use of osticket models ($meta) and their interpretation in terms of osticket custom ORM, I couldn't find much documentation on the forums, tough comprehension about this matter is paramount to design any complex modification.
I have also looked up different system classes in search of directions on its use and I think I have a glimpse on how to use it wrt making simple queries.. tough some bits and tricks still remain a mystery to me.
I have been struggling with what I think is a very simple query, I want to join two tables using an intermediary table, e.g: "select * from a inner join b on (a.id=b.a_id) inner join c on b.id = c.b_id;" but since the left operand on any "join" "constraint" is local (relative to the main table) I can't translate this type of query exactly to the model I want.
I have had some moderate success using the intermediary table has the main table, e.g:
static $meta = array(
'table' => 'b'
'pk' => array('id'),
'select_related' => array('a', 'c'),
'joins' => array(
'a' => array(
'constraint' => array('a_id' => 'A.id'),
),
'c' => array(
'constraint' => array('id' => 'C.b_id'),
),
)
);
But this feels strange, as if I had two intermediate tables this approach wouldn't work.
I have also played around with 'reverse' definitions but I simply can't figure it out. If anyone could point me in the right direction, or point me to an example class it would be greatly appreciated.
Best regards,