laravel4-datatables-package icon indicating copy to clipboard operation
laravel4-datatables-package copied to clipboard

Adding backticks to column names in the filtering function

Open torocatala opened this issue 11 years ago • 3 comments

Hello, I'm using this package and I faced a problem where i had as column name 'group' (from the package https://github.com/Waavi/translation), this caused a problem cos 'group' is a reserved word in mysql. I added some code to the filtering function and now it adds backsticks to the column names and it works fine for me. There is probably a better aproach to this problem, like adding the filtering in an external function or not using reserverd words as column names. Anyway here is the snippet of the code I added to the function.

if (strpos($column,'.') != false) {
    $columnarr=explode('.',$column);
    foreach ($columnarr as $key => $value) {
        $value = "`".$value."`";
    }
    $column = implode('.',$columnarr);
}else{
    $column = "`".$column."`";
}

I added it after the line 410, inside the else.

torocatala avatar Jun 25 '14 11:06 torocatala

Added to TO DO list for 1.4.1 release #122

ktunkiewicz avatar Jul 25 '14 07:07 ktunkiewicz

This bug still not solved?

douglaspossas avatar Nov 05 '14 20:11 douglaspossas

Can you create a pull request? be aware that this doesnt introduce new bugs like if the column is a function like: sum(value) or already escaped doubleticks this is just of the top of my head

MarkVaughn avatar Nov 05 '14 21:11 MarkVaughn