Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
Order by escape macro
givanzc0f2a6af1c41
diff --git a/admin/sql/mysqli/order.sql b/admin/sql/mysqli/order.sqlindex dbd0aa8..062f798 100644--- a/admin/sql/mysqli/order.sql+++ b/admin/sql/mysqli/order.sql@@ -100,7 +100,8 @@-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values@IF isset(:order_by)THEN- ORDER BY $order_by $direction+ -- ORDER BY $order_by $direction+ ORDER BY order.@ESC(:order_by) @ESC(:direction)@ELSEORDER BY order_id DESCEND @IFdiff --git a/admin/sql/mysqli/product_variant.sql b/admin/sql/mysqli/product_variant.sqlindex 76b6979..24f6cb2 100644--- a/admin/sql/mysqli/product_variant.sql+++ b/admin/sql/mysqli/product_variant.sql@@ -40,7 +40,8 @@-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values@IF isset(:order_by)THEN- ORDER BY product_variant.$order_by $direction+ -- ORDER BY $order_by $direction+ ORDER BY product_variant.@ESC(:order_by) @ESC(:direction)@ELSEORDER BY product_variant.product_variant_id ASCEND @IFdiff --git a/admin/sql/mysqli/user.sql b/admin/sql/mysqli/user.sqlindex 03d1e6d..681d62b 100644--- a/admin/sql/mysqli/user.sql+++ b/admin/sql/mysqli/user.sql@@ -51,7 +51,8 @@-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values@IF isset(:order_by)THEN- ORDER BY user.$order_by $direction+ -- ORDER BY $order_by $direction+ ORDER BY user.@ESC(:order_by) @ESC(:direction)@ELSEORDER BY user.user_id DESCEND @IFdiff --git a/admin/sql/pgsql/order.sql b/admin/sql/pgsql/order.sqlold mode 100755new mode 100644index 728a2d2..8573618--- a/admin/sql/pgsql/order.sql+++ b/admin/sql/pgsql/order.sql@@ -100,9 +100,10 @@-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values@IF isset(:order_by)THEN- ORDER BY $order_by $direction+ -- ORDER BY $order_by $direction+ ORDER BY "order".@ESC(:order_by) @ESC(:direction)@ELSE- ORDER BY order_id DESC+ ORDER BY "order".order_id DESCEND @IF@SQL_LIMIT(:start, :limit);diff --git a/admin/sql/pgsql/product_variant.sql b/admin/sql/pgsql/product_variant.sqlindex d3b8db5..72cba48 100644--- a/admin/sql/pgsql/product_variant.sql+++ b/admin/sql/pgsql/product_variant.sql@@ -40,7 +40,8 @@-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values@IF isset(:order_by)THEN- ORDER BY product_variant.$order_by $direction+ -- ORDER BY $order_by $direction+ ORDER BY product_variant.@ESC(:order_by) @ESC(:direction)@ELSEORDER BY product_variant.product_variant_id ASCEND @IF@@ -82,7 +83,8 @@INSERT INTO product_variant( @KEYS(:product_variant) )- VALUES (:product_variant );+ VALUES (:product_variant )+ ON CONFLICT ("product_variant_id") DO UPDATE SET @LIST(:product_variant);ENDdiff --git a/admin/sql/pgsql/user.sql b/admin/sql/pgsql/user.sqlold mode 100755new mode 100644index 857407a..7bfbf2c--- a/admin/sql/pgsql/user.sql+++ b/admin/sql/pgsql/user.sql@@ -51,7 +51,8 @@-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values@IF isset(:order_by)THEN- ORDER BY "user".$order_by $direction+ -- ORDER BY $order_by $direction+ ORDER BY "user".@ESC(:order_by) @ESC(:direction)@ELSEORDER BY "user".user_id DESCEND @IFdiff --git a/admin/sql/sqlite/order.sql b/admin/sql/sqlite/order.sqlold mode 100755new mode 100644index 2260c12..fc55031--- a/admin/sql/sqlite/order.sql+++ b/admin/sql/sqlite/order.sql@@ -100,9 +100,10 @@-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values@IF isset(:order_by)THEN- ORDER BY $order_by $direction+ -- ORDER BY $order_by $direction+ ORDER BY `order`.@ESC(:order_by) @ESC(:direction)@ELSE- ORDER BY order_id DESC+ ORDER BY `order`.order_id DESCEND @IF@SQL_LIMIT(:start, :limit);diff --git a/admin/sql/sqlite/product_variant.sql b/admin/sql/sqlite/product_variant.sqlindex 3762e27..ded12b2 100644--- a/admin/sql/sqlite/product_variant.sql+++ b/admin/sql/sqlite/product_variant.sql@@ -40,7 +40,8 @@-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values@IF isset(:order_by)THEN- ORDER BY product_variant.$order_by $direction+ -- ORDER BY $order_by $direction+ ORDER BY product_variant.@ESC(:order_by) @ESC(:direction)@ELSEORDER BY product_variant.product_variant_id ASCEND @IFdiff --git a/admin/sql/sqlite/user.sql b/admin/sql/sqlite/user.sqlold mode 100755new mode 100644index f088638..0d905cf--- a/admin/sql/sqlite/user.sql+++ b/admin/sql/sqlite/user.sql@@ -51,7 +51,8 @@-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values@IF isset(:order_by)THEN- ORDER BY user.$order_by $direction+ -- ORDER BY $order_by $direction+ ORDER BY user.@ESC(:order_by) @ESC(:direction)@ELSEORDER BY user.user_id DESCEND @IFdiff --git a/system/sqlp/config.php b/system/sqlp/config.phpindex d3cf34e..c0dde25 100755--- a/system/sqlp/config.php+++ b/system/sqlp/config.php@@ -55,6 +55,7 @@ return//'END @EACH' => 'T_EACH_END','@SQL_COUNT\(.+?\)' => 'T_SQL_COUNT','@SQL_LIMIT\(.+?\)' => 'T_SQL_LIMIT',+ '@ESC\(.+?\)' => 'T_ESC','.+?' => 'T_SQL',],@@ -124,6 +125,15 @@ PHPPHP],+ 'T_ESC' => [+ '/@ESC\s*\(\s*:?(?<column>.+?)\s*\)/ms',+ <<<'PHP'+ ';+ $sql .= preg_replace('/\W+/', '', $params['%column'] ?? '');+ $sql .= '+PHP+ ],+//'T_EACH_START' => 'EACH()',//'T_EACH_END' => '}','@SQL_COUNT\(.+?\)' => 'T_SQL_COUNT',diff --git a/system/sqlp/sqlp.php b/system/sqlp/sqlp.phpindex e74e56f..e566875 100644--- a/system/sqlp/sqlp.php+++ b/system/sqlp/sqlp.php@@ -574,7 +574,9 @@ class Sqlp {}//clean empty sql strings- $statement = preg_replace('@\s*\$sql .= \'\s*\';@ms', '', $statement);+ $statement = preg_replace('@\$sql .= \'\s+\n\s*\';@ms', '$sql .= \' \';', $statement);+ $statement = preg_replace('@\s*\$sql .= \'\';@ms', '', $statement);+ //$statement = preg_replace('@\s*\$sql .= \'\s*\';@ms', '', $statement);if (isset($fetch[$qIndex])) {$method['fetch'] = $this->fetchType($fetch[$qIndex]);