summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Context.php14
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;
}
}