How can I alias fields in the same table?
How can I alias fields in the same table?
Here are my first part of codes:
$editor = new Editor($db, 'tableA as main', 'id');
$editor -> fields(
Field::inst('main.id'),
Field::inst('main.isApproved'),
Field::inst('tableC.name')
)
->leftJoin('tableC', 'main.approveID', '=', 'tableC.id');
my second part of PHP codes are:
$editor = new Editor($db, 'tableA as main', 'id');
$editor -> fields(
Field::inst('tableC.name')
)
->leftJoin('tableB', 'tableB.userID', '=', 'tableA.id')
->leftJoin('tableC', 'tableC.id', '=', 'tableB.scoreID')
->where('main.id', $userID);
In the first part it will return one record of 'tableC.name', and in the second part it will return multiple records of 'tableC.name', and now I want to combine these two parts into one $editor called by only one Ajax, because both of results will be populated into the same datatable at the front-end side. If I do two seperate Ajax calls, the sorting, filtering and downloading functions will be broken for some columns because datatable will only know the first object but not the second object.
I have done some research on Mjoin-name() and aliasParentTable() but didn't find a solution.
Please help!
Answers
real Table aliases:
https://editor.datatables.net/manual/php/joins