Hi,
I'm using phalcon-datatables this is a datatables adapter for Phalcon.
The where condition not working for the global search. Here is my code :
use \DataTables\DataTable;
class TestController extends \Phalcon\Mvc\Controller {
public function indexAction() {
if ($this->request->isAjax()) {
$builder = $this->modelsManager->createBuilder()
->columns('id, name, email, age,login')
->from('Example\Models\User');
->where("age = :age:", array("age" => 30))
$dataTables = new DataTable();
$dataTables->fromBuilder($builder)->sendResponse();
}
}
}
I noticed a problem inside the library in this class -> Github line 21-23
$this->bind('global_search', function($column, $search) {
$this->builder->orWhere("{$column} LIKE :key_{$column}:", ["key_{$column}" => "%{$search}%"]);
});
For the global search the orWhere condition is used and I have a problem with that because this will ignore my first where condition ->where("age = :age:", array("age" => 30))
I want to make this query with QueryBuilder to modify this class:
SELECT *
FROM `users`
WHERE age = 30
AND (name like '%d%'
OR email like '%d%'
OR login like '%d%')
How can I edit the bind function to make it work ?