From 7c1f8a89cff2ef27658196cf4391f7535ce3bf60 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Thu, 3 Sep 2020 10:29:17 +0200 Subject: make sure connection exists for escape_name same as escape_string --- it_dbi.class | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'it_dbi.class') diff --git a/it_dbi.class b/it_dbi.class index 217b572..d84c194 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -306,7 +306,7 @@ function _set($tags, $force = false) { $expressions = $this->_expressions($tags, $force); - return $expressions ? 'SET ' . implode(', ', it::map(fn ($k, $v) => $this->_escape_name($k) . "=$v", $expressions)) : ''; + return $expressions ? 'SET ' . implode(', ', it::map(fn ($k, $v) => $this->escape_name($k) . "=$v", $expressions)) : ''; } /** @@ -319,7 +319,7 @@ function _values($tags, $force = false) $result = ''; if ($expressions) - $result = '(' . implode(', ', it::map(fn ($k) => $this->_escape_name($k), $expressions)) . ') VALUES (' . implode(', ', array_values($expressions)) . ')'; + $result = '(' . implode(', ', it::map(fn ($k) => $this->escape_name($k), $expressions)) . ') VALUES (' . implode(', ', array_values($expressions)) . ')'; return $result; } @@ -910,6 +910,16 @@ function escape_string($str) return $this->_escape_string($str); } +/** + * Escapes a name/identifier for use in a DB query + * @param The identifier to be quoted + * @return The quoted value + */ +function escape_name($str) +{ + $this->_connect(); + return $this->_escape_name($str); +} /** * INTERNAL: Store information about a table's fields in $this->_fields, possibly from cache. -- cgit v1.2.3