Search operators with server-side (PHP)

Search operators with server-side (PHP)

BalubaerBalubaer Posts: 14Questions: 2Answers: 0
edited August 10 in Free community support


I was looking around to allow me to implement more or less complex search operators (mostly simple compare operators like <, >, <=, >= etc.) and was trying to implement it in the preGet event.

But implementing this I faced the problem that the origin search parameters of the request cannot be changed/removed, so e.g. implementing a search where the parameters might be something like

columns[2][data]: id
columns[2][name]: id
columns[2][searchable]: true
columns[2][orderable]: true
columns[2][search][value]: > 12965
columns[2][search][regex]: false

and the preGet event code something like

$editor->where(function($q) {
// code shortened
// parsing $_POST parameters
    $field_name = 'id'; // as example
    $operator = '>'; // as example
    $value = '12965'; // as example
    $q->where($field_name, $value, $operator);
// code shortened

the original search parameter will prevent a correct result, because the SQL will be something like (excerpt from the debug output)

"bindings": [
    // debug shortened
        "name": ":where_9",
        "type": null,
        "value": "12965"
        "name": ":where_10",
        "type": null,
        "value": "%> 12965%"
"query": "SELECT  `id` as 'id' FROM  `projectsoverview` WHERE `id` > :where_9 AND `id` like :where_10  LIMIT 120"

where the original request data is stored in the where_10 clause.

Is there any way to use the server-side lib of editor and implementing a custom search (in the backend)? I know that there will be some filter libs for the frontend and regular expressions, too, but it might be a bit too complex to implement a search with comparing (sql-like) operators with regular expressions.

Any help is appreciated.



  • allanallan Posts: 47,496Questions: 1Answers: 6,751 Site admin

    Hi Dennis,

    One quick work around would be to use $_POST['columns'][2]['search']['value'] = ''; once you've parsed it.

    Its a bit of a hack, but it makes sense given how you are using the built in parameter (good idea that I like it!).


Sign In or Register to comment.