summaryrefslogtreecommitdiff
path: root/it_dbi.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_dbi.class')
-rw-r--r--it_dbi.class34
1 files changed, 31 insertions, 3 deletions
diff --git a/it_dbi.class b/it_dbi.class
index c9cef54..2923bf3 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -915,6 +915,26 @@ function escape_string($str)
}
/**
+ * Escapes an int for use in a DB query
+ * @param The int to be quoted
+ * @return The quoted value
+ */
+static function escape_int($val)
+{
+ return "'" . intval($val) . "'";
+}
+
+/**
+ * Escapes a float for use in a DB query
+ * @param The float to be quoted
+ * @return The quoted value
+ */
+static function escape_float($val)
+{
+ return "'" . floatval($val) . "'";
+}
+
+/**
* Escapes a name/identifier for use in a DB query
* @param The identifier to be quoted
* @return The quoted value
@@ -941,7 +961,6 @@ static function escape_bool($bool)
*/
function _get_field_info()
{
- $result = array();
$dbid = "{$this->_p['user']}@{$this->_p['server']}:{$this->_p['db']}";
$state = static::_state_get($dbid);
@@ -956,8 +975,16 @@ function _get_field_info()
$this->_convertfunc[$name] = $field['_convertfunc'];
$this->_escapefunc[$name] = $field['_escapefunc'];
}
- else if (preg_match('/^(tiny|small|medium|)int|^float|^double$/', $field['Type']))
- $this->_convertfunc[$name] = it::match('int', $field['Type']) ? "intval" : "floatval";
+ else if (preg_match('/^(tiny|small|medium|)int/', $field['Type']))
+ {
+ $this->_convertfunc[$name] = "intval";
+ $this->_escapefunc[$name] = static::class . "::escape_int";
+ }
+ else if (preg_match('/^float|^double$/', $field['Type']))
+ {
+ $this->_convertfunc[$name] = "floatval";
+ $this->_escapefunc[$name] = static::class . "::escape_float";
+ }
}
$this->_fieldnames = "," . implode(",", array_keys((array)$this->_fields)) . ",";
@@ -979,6 +1006,7 @@ function _get_field_info()
$this->_localizedfields = $state['localizedfields'][$this->_p['table']];
}
+ $result = array();
foreach((array)$this->_fields as $field)
{
if ($field['Key'] == 'PRI')