laravel4-datatables-package
laravel4-datatables-package copied to clipboard
Adding backticks to column names in the filtering function
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.
Added to TO DO list for 1.4.1 release #122
This bug still not solved?
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