summaryrefslogtreecommitdiff
path: root/it_dbi.class
diff options
context:
space:
mode:
authorUrban Müller2017-05-17 16:17:31 +0200
committerUrban Müller2017-05-17 16:17:31 +0200
commit64fa3b1fec144fa3f283b8c9391e8caa32117a57 (patch)
treefc8748e21e97557d915e3897ffab0122c6d3d366 /it_dbi.class
parent972605c453a80518e82dbce9da48b99f506336c5 (diff)
downloaditools-64fa3b1fec144fa3f283b8c9391e8caa32117a57.tar.gz
itools-64fa3b1fec144fa3f283b8c9391e8caa32117a57.tar.bz2
itools-64fa3b1fec144fa3f283b8c9391e8caa32117a57.zip
check for correct case of field names
Diffstat (limited to 'it_dbi.class')
-rw-r--r--it_dbi.class5
1 files changed, 5 insertions, 0 deletions
diff --git a/it_dbi.class b/it_dbi.class
index c814aa6..7bed262 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -43,6 +43,7 @@ class it_dbi
var $_key; # Key of currently loaded record or null (public readonly)
var $_fields; # Array of name => array(Field,Type,Null,Key,Default,Extra,Length) of fields (public readonly)
+ var $_fieldnames; # All field names in schema for case mismatch alert
var $_convertfunc; # Array of name => convert function (currently intval and floatval) for this field's values
var $_link; # DB link identifier (private)
var $_dbid; # string identifying db connection. used for _state_purgeshared from outside
@@ -245,6 +246,9 @@ function _set($tags, $allfields = false)
$result = array();
foreach((array)$tags as $field => $value)
{
+ if (!$this->_fields[trim($field, "-")] && it::match("," . trim($field, "-") . ",", $this->_fieldnames))
+ it::error("case mismatch on field " . trim($field, "-") . ", valid fields $this->_fieldnames");
+
if (substr($field, 0, 1) === "-" && !$this->_fields[trim($field, "-")] && $this->_fields['dyncols'])
$dyns[] = $this->escape_string(trim($field, "-")) . ", $value";
else if (substr($field, 0, 1) === '-') # Unquoted value (always added)
@@ -834,6 +838,7 @@ function _get_field_info()
if (preg_match('/^(tiny|small|medium|)int|^float|^double/', $field['Type']))
$this->_convertfunc[$field['Field']] = it::match('int', $field['Type']) ? "intval" : "floatval";
}
+ $this->_fieldnames = "," . join(",", array_keys((array)$this->_fields)) . ",";
# Consider all fields which have _{localized_defaultlanguage} suffix as localized
foreach (preg_grep('/_' . $this->_p['localized_defaultlanguage'] . '$/', array_keys((array)$this->_fields)) as $field)