From 627ca5aef6335f1b5ed2edb2d10809e215a4459f Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Fri, 2 Dec 2016 17:21:21 +0000 Subject: [PATCH] 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 --- .datatables-commit-sync | 2 +- examples/server_side/scripts/ssp.class.php | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.datatables-commit-sync b/.datatables-commit-sync index 42c9be36..aa4af690 100644 --- a/.datatables-commit-sync +++ b/.datatables-commit-sync @@ -1 +1 @@ -6646b5f07d2bc16733788fdda9cfda91cdb33dc9 +fe9077c9de9f041a246897d953610ddf9451b56b diff --git a/examples/server_side/scripts/ssp.class.php b/examples/server_side/scripts/ssp.class.php index 060d9d76..530a388b 100644 --- a/examples/server_side/scripts/ssp.class.php +++ b/examples/server_side/scripts/ssp.class.php @@ -242,7 +242,7 @@ class SSP { // Main query to actually get the data $data = self::sql_exec( $db, $bindings, - "SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", self::pluck($columns, 'db'))."` + "SELECT `".implode("`, `", self::pluck($columns, 'db'))."` FROM `$table` $where $order @@ -250,8 +250,10 @@ class SSP { ); // Data set length after filtering - $resFilterLength = self::sql_exec( $db, - "SELECT FOUND_ROWS()" + $resFilterLength = self::sql_exec( $db, $bindings, + "SELECT COUNT(`{$primaryKey}`) + FROM `$table` + $where" ); $recordsFiltered = $resFilterLength[0][0]; @@ -262,7 +264,6 @@ class SSP { ); $recordsTotal = $resTotalLength[0][0]; - /* * Output */ @@ -332,7 +333,7 @@ class SSP { // Main query to actually get the data $data = self::sql_exec( $db, $bindings, - "SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", self::pluck($columns, 'db'))."` + "SELECT `".implode("`, `", self::pluck($columns, 'db'))."` FROM `$table` $where $order @@ -340,8 +341,10 @@ class SSP { ); // Data set length after filtering - $resFilterLength = self::sql_exec( $db, - "SELECT FOUND_ROWS()" + $resFilterLength = self::sql_exec( $db, $bindings, + "SELECT COUNT(`{$primaryKey}`) + FROM `$table` + $where" ); $recordsFiltered = $resFilterLength[0][0];