1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-18 11:52:11 +01:00

Fix: Add field quotes (`) to the main server-side processing script. For most cases this will make no difference, but some columns might have a special character in them (- for example) and need this quoting.

This commit is contained in:
Allan Jardine 2011-12-06 10:59:20 +00:00
parent 07c3d3f5a6
commit 8795d97194

View File

@ -61,8 +61,8 @@
{ {
if ( $_GET[ 'bSortable_'.intval($_GET['iSortCol_'.$i]) ] == "true" ) if ( $_GET[ 'bSortable_'.intval($_GET['iSortCol_'.$i]) ] == "true" )
{ {
$sOrder .= $aColumns[ intval( $_GET['iSortCol_'.$i] ) ]." $sOrder .= "`".$aColumns[ intval( $_GET['iSortCol_'.$i] ) ]."` ".
".mysql_real_escape_string( $_GET['sSortDir_'.$i] ) .", "; mysql_real_escape_string( $_GET['sSortDir_'.$i] ) .", ";
} }
} }
@ -86,7 +86,7 @@
$sWhere = "WHERE ("; $sWhere = "WHERE (";
for ( $i=0 ; $i<count($aColumns) ; $i++ ) for ( $i=0 ; $i<count($aColumns) ; $i++ )
{ {
$sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR "; $sWhere .= "`".$aColumns[$i]."` LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ";
} }
$sWhere = substr_replace( $sWhere, "", -3 ); $sWhere = substr_replace( $sWhere, "", -3 );
$sWhere .= ')'; $sWhere .= ')';
@ -105,7 +105,7 @@
{ {
$sWhere .= " AND "; $sWhere .= " AND ";
} }
$sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' "; $sWhere .= "`".$aColumns[$i]."` LIKE '%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' ";
} }
} }
@ -115,7 +115,7 @@
* Get data to display * Get data to display
*/ */
$sQuery = " $sQuery = "
SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))." SELECT SQL_CALC_FOUND_ROWS `".str_replace(" , ", " ", implode("`, `", $aColumns))."`
FROM $sTable FROM $sTable
$sWhere $sWhere
$sOrder $sOrder
@ -133,7 +133,7 @@
/* Total data set length */ /* Total data set length */
$sQuery = " $sQuery = "
SELECT COUNT(".$sIndexColumn.") SELECT COUNT(`".$sIndexColumn."`)
FROM $sTable FROM $sTable
"; ";
$rResultTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error()); $rResultTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());