summaryrefslogtreecommitdiff
path: root/includes/database/database.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/database/database.inc')
-rw-r--r--includes/database/database.inc28
1 files changed, 28 insertions, 0 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc
index 73cb243e5..ca6023f2d 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -810,6 +810,34 @@ abstract class DatabaseConnection extends PDO {
}
/**
+ * Escapes an alias name string.
+ *
+ * Force all alias names to be strictly alphanumeric-plus-underscore. In
+ * contrast to DatabaseConnection::escapeField() /
+ * DatabaseConnection::escapeTable(), this doesn't allow the period (".")
+ *
+ * @return
+ * The sanitized field name string.
+ */
+ public function escapeAlias($field) {
+ return preg_replace('/[^A-Za-z0-9_]+/', '', $field);
+ }
+
+ /**
+ * Escapes a alias name string.
+ *
+ * Force all alias names to be strictly alphanumeric-plus-underscore. In
+ * contrast to DatabaseConnection::escapeField() /
+ * DatabaseConnection::escapeTable(), this doesn't allow the point.
+ *
+ * @return
+ * The sanitized field name string.
+ */
+ public function escapeAlias($field) {
+ return preg_replace('/[^A-Za-z0-9_]+/', '', $field);
+ }
+
+ /**
* Escapes characters that work as wildcard characters in a LIKE pattern.
*
* The wildcard characters "%" and "_" as well as backslash are prefixed with