Dear friends,
I have two tables and they have some columns matching in name. The tables are "ticket" and "dept"
Both do have "id" and "name" columns
My approach is to use the Codeigniter model
so I have TicketModel
PHP Code:
<?php
namespace App\Models;
class TicketModel extends \CodeIgniter\Model
{
protected $table = 'ticket';
}
and I have TicketController
PHP Code:
<?php
namespace App\Controllers;
class TicketController extends BaseController
{
public function showTickets()
{
$model = new \App\Models\TicketModel();
$data = $model ->where('ticket.dept_id', '52')
->join('dept', 'ticket.dept_id = dept.id')
->orderBy('ticket.date', 'desc')
->findAll();
dd($data);
everything works, but dd($data); shows that the join result show only one "id" column and only one "name" column. To be precise, the id and the name columns are filled with the 'dept' table values .. but I need also ticket.id and ticket.name columns
This should be solved with MySQL aliases
But... where/how do I insert the aliases statement? meant working with the approach
PHP Code:
$model = new \App\Models\TicketModel();
, thank you for hinting