I'm using an MVC PHP framework and I managed to write all models then I completed all backend staff. Later on on the frontend development to make everything easier and faster I found my self in-need to use Datatables plug-in, but this compels me to send response back in a specific format, so I wrote a plug-in that changes the returned values from models to the format needed in Datatables.
Example 1 - Model with my own plugin:
$this->myModel->setCostRange(50, 93);
$this->myModel->setCustomerId(123);
$results = $this->myModel->search();
// Then I use my plugin this way to change the response format
$results = $this->_buildGrid($results);
That was my solution, although Datatables provide many backend plugins to make queries instead of model, but as I believe this conflicts code separation principle and MVC logic.
Example 2 - no model use:
$g = new \Data\Grid("tableName");
$g->addColumn(
"name",
"Name"
);
$g->addColumn(
"userEmail",
"Email"
);
$g->render($_POST);
Any advises!