diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2016-02-11 17:38:33 +0200 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2016-02-11 17:39:33 +0200 |
commit | de8b3efbbca418f7c867909dbcb3fbe4b4a20497 (patch) | |
tree | c110e9ec63c3d278c060e8965435981ac2da83e4 | |
parent | 38b10f585ac012554f8a3d0dd6e7e3fd255ff94f (diff) | |
download | sql-parser-de8b3efbbca418f7c867909dbcb3fbe4b4a20497.zip sql-parser-de8b3efbbca418f7c867909dbcb3fbe4b4a20497.tar.gz sql-parser-de8b3efbbca418f7c867909dbcb3fbe4b4a20497.tar.bz2 |
Context: Added custom mode that avoids escaping when possible.v3.2.0
-rw-r--r-- | src/Context.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Context.php b/src/Context.php index 7637953..a62fa16 100644 --- a/src/Context.php +++ b/src/Context.php @@ -190,6 +190,13 @@ abstract class Context // https://dev.mysql.com/doc/refman/5.0/en/sql-mode.html#sqlmode_strict_trans_tables const STRICT_TRANS_TABLES = 1048576; + // Custom modes. + + // The table and column names and any other field that must be escaped will + // not be. + // Reserved keywords are being escaped regardless this mode is used or not. + const NO_ENCLOSING_QUOTES = 1073741824; + /* * Combination SQL Modes * https://dev.mysql.com/doc/refman/5.0/en/sql-mode.html#sql-mode-combo @@ -520,9 +527,16 @@ abstract class Context return $str; } + if ((static::$MODE & Context::NO_ENCLOSING_QUOTES) + && (!static::isKeyword($str, true)) + ) { + return $str; + } + if (static::$MODE & Context::ANSI_QUOTES) { $quote = '"'; } + return $quote . str_replace($quote, $quote . $quote, $str) . $quote; } } |