1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-20 18:54:15 +01:00

Fix: Remove MySQL specific commands from demo SSP class

- SQL_CALC_FOUND_ROWS was used to try and speed the queries up, and that
  works well for MySQL, but it confuses anyone who tries to modify this
  script for other databases.
- Field escaping should possibly be considered in future as well
This commit is contained in:
Allan Jardine 2016-12-02 17:21:21 +00:00
parent 632f449467
commit 627ca5aef6
2 changed files with 11 additions and 8 deletions

View File

@ -1 +1 @@
6646b5f07d2bc16733788fdda9cfda91cdb33dc9 fe9077c9de9f041a246897d953610ddf9451b56b

View File

@ -242,7 +242,7 @@ class SSP {
// Main query to actually get the data // Main query to actually get the data
$data = self::sql_exec( $db, $bindings, $data = self::sql_exec( $db, $bindings,
"SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", self::pluck($columns, 'db'))."` "SELECT `".implode("`, `", self::pluck($columns, 'db'))."`
FROM `$table` FROM `$table`
$where $where
$order $order
@ -250,8 +250,10 @@ class SSP {
); );
// Data set length after filtering // Data set length after filtering
$resFilterLength = self::sql_exec( $db, $resFilterLength = self::sql_exec( $db, $bindings,
"SELECT FOUND_ROWS()" "SELECT COUNT(`{$primaryKey}`)
FROM `$table`
$where"
); );
$recordsFiltered = $resFilterLength[0][0]; $recordsFiltered = $resFilterLength[0][0];
@ -262,7 +264,6 @@ class SSP {
); );
$recordsTotal = $resTotalLength[0][0]; $recordsTotal = $resTotalLength[0][0];
/* /*
* Output * Output
*/ */
@ -332,7 +333,7 @@ class SSP {
// Main query to actually get the data // Main query to actually get the data
$data = self::sql_exec( $db, $bindings, $data = self::sql_exec( $db, $bindings,
"SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", self::pluck($columns, 'db'))."` "SELECT `".implode("`, `", self::pluck($columns, 'db'))."`
FROM `$table` FROM `$table`
$where $where
$order $order
@ -340,8 +341,10 @@ class SSP {
); );
// Data set length after filtering // Data set length after filtering
$resFilterLength = self::sql_exec( $db, $resFilterLength = self::sql_exec( $db, $bindings,
"SELECT FOUND_ROWS()" "SELECT COUNT(`{$primaryKey}`)
FROM `$table`
$where"
); );
$recordsFiltered = $resFilterLength[0][0]; $recordsFiltered = $resFilterLength[0][0];