Editor PHP Lib small enhancement

Editor PHP Lib small enhancement

flamesflames Posts: 4Questions: 1Answers: 0
edited June 2018 in Editor

Hello Allan,

there is a little thing, that could be improved in the DT Editors PHP Library, in file
./php/Editor/Editor.php
on Line 1543 change this
$query->where( $this->_ssp_field( $http, $i ), '%'.$search.'%', 'like' );
to this
$query->where( $this->_ssp_field( $http, $i ), $search, 'like' );

As You see, just removed the % in the Like clause, so a user could decide in the frontend if he wants an explicit columns filter with the ability to search begining of string 'abc%', end of string '%xyz' or have an precise match 'abcxyz'

in Js this would look like (a snip from my project)
filterBranch = '%'+$(this).attr('id')+"[0-9][0-9]";
oTableBranches.columns(7).search(filterBranch, true, false, false).draw();

I am asking for this, because i use Datatables (+Editor) with PHP and MS SQL Server 2008, which does not support Regular Expressions. Also in case of MS SQL it could be nice to disable those % if regex = true and smart = false. even regex is not supported, this might be a compromise.

Thanks in advance.

Best,
Arthur

Replies

  • allanallan Posts: 63,192Questions: 1Answers: 10,412 Site admin

    Hi Arthur,

    Thanks for the suggestion! This assumes that the end user knows what a % or ? wildcard are - while it would be possible to add some text on the client-side to let them know, I feel that is something that should be optional. To that end, I think the current implementation will stay, but its quite possible for you to modify the code to suit your needs (indeed I would encourage it!).

    Allan

  • flamesflames Posts: 4Questions: 1Answers: 0

    Thanks Allan,

    shure, i did modified the code to my needs and documented it, so on update of libraries i won't forget to reimplement it.
    since in the php lib is no regex feature yet, i added an if/else statement for the regex param. if regex false the default behaviour is used with '%'+$search+'%', if regex true, wildcards removed.

    still, i guess there is a little missunderstanding. I don't mean the enduser (the visitor of frontend) who needs to know what those placeholders are. I mean the developer of the frontend should be able to implement it.

    I actually like the editor php lib, so next step will be to implement a fully working regex fature (for database engines which support it) and maybe mongodb/nosql support (need to get deeper into it first).

    Best,
    Arthur

This discussion has been closed.