`$builder = $this->worktimes->builder('worktimes w')
->select('w.id,
w.created_at,
w.work_at,
w.time_at,
CASE
WHEN w.object = "firms" THEN "Firma"
WHEN w.object = "persons" THEN "Osoba"
END as object,
CASE
WHEN w.object = "firms" THEN f.firmname
WHEN w.object = "persons" THEN CONCAT(p.lastname, " ", p.firstname)
END as objectname,
c.name,
w.note', false)
->join('firms f', 'f.id = w.object_id', 'left outer')
->join('persons p', 'p.id = w.object_id', 'left outer')
->join('categories c', 'c.id = w.categorie_id')
->where('w.deleted_at', null);
When remove :
CASE WHEN w.object = "firms" THEN "Firma" WHEN w.object = "persons" THEN "Osoba" END as object, CASE WHEN w.object = "firms" THEN f.firmname WHEN w.object = "persons" THEN CONCAT(p.lastname, " ", p.firstname) END as objectname,
Query is ok
After upgrade form 4.2.1 > 4.2.2 i have error durign response .
====
finaly i change all CASE to separate select:
->select("CASE
WHEN w.object = "firms" THEN "Firma"
WHEN w.object = "persons" THEN "Osoba"
END as object", false)
->select("CASE
WHEN w.object = "firms" THEN f.firmname
WHEN w.object = "persons" THEN CONCAT(p.lastname, " ", p.firstname)
END as objectname", false);
`$builder = $this->worktimes->builder('worktimes w') ->select('w.id, w.created_at,
w.work_at,
w.time_at,
CASE WHEN w.object = "firms" THEN "Firma" WHEN w.object = "persons" THEN "Osoba" END as object, CASE WHEN w.object = "firms" THEN f.firmname WHEN w.object = "persons" THEN CONCAT(p.lastname, " ", p.firstname) END as objectname, c.name, w.note', false) ->join('firms f', 'f.id = w.object_id', 'left outer') ->join('persons p', 'p.id = w.object_id', 'left outer') ->join('categories c', 'c.id = w.categorie_id') ->where('w.deleted_at', null);
$return = DataTable::of($builder) ->setSearchableColumns(['w.created_at', 'w.updated_at', 'w.work_at', 'w.time_at', 'w.note', 'f.firmname', 'p.firstname', 'p.lastname', 'c.name'])
->edit('time_at', function ($row) { return "
Error:
{ "title": "ErrorException", "type": "ErrorException", "code": 500, "message": "Undefined array key 4", "file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTableColumnDefs.php", "line": 308, "trace": [ { "file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTableColumnDefs.php", "line": 308, "function": "errorHandler", "class": "CodeIgniter\Debug\Exceptions", "type": "->", "args": [ 2, "Undefined array key 4", "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTableColumnDefs.php", 308 ] }, { "file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTableColumnDefs.php", "line": 17, "function": "initFromBuilder", "class": "Hermawan\DataTables\DataTableColumnDefs", "type": "->", "args": [ { "QBGroupBy": [], "QBOrderBy": [], "QBNoEscape": [ false ] } ] }, { "file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTable.php", "line": 35, "function": "construct", "class": "Hermawan\DataTables\DataTableColumnDefs", "type": "->", "args": [ { "QBGroupBy": [], "QBOrderBy": [], "QBNoEscape": [ false ] } ] }, { "file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTable.php", "line": 46, "function": "construct", "class": "Hermawan\DataTables\DataTable", "type": "->", "args": [ { "QBGroupBy": [], "QBOrderBy": [], "QBNoEscape": [ false ] } ] },
When remove :
CASE WHEN w.object = "firms" THEN "Firma" WHEN w.object = "persons" THEN "Osoba" END as object, CASE WHEN w.object = "firms" THEN f.firmname WHEN w.object = "persons" THEN CONCAT(p.lastname, " ", p.firstname) END as objectname,
Query is ok
After upgrade form 4.2.1 > 4.2.2 i have error durign response .
====
finaly i change all CASE to separate select: ->select("CASE WHEN w.object = "firms" THEN "Firma" WHEN w.object = "persons" THEN "Osoba" END as object", false) ->select("CASE WHEN w.object = "firms" THEN f.firmname WHEN w.object = "persons" THEN CONCAT(p.lastname, " ", p.firstname) END as objectname", false);
and work ok