diff options
Diffstat (limited to 'it_dbi.class')
-rw-r--r-- | it_dbi.class | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/it_dbi.class b/it_dbi.class index 71b6c95..b681102 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -96,7 +96,7 @@ function __construct($p = array(), $query = null) array_shift($args); call_user_func_array(array($this, "select"), $args); } - elseif (isset($query)) + else if (isset($query)) $this->read($query); } else @@ -248,7 +248,8 @@ function _expressions($tags, $force = false) foreach((array)$tags as $field => $value) { - if (is_int($field)) { /* no key specified; pass on unchanged */ + if (is_int($field)) # No key specified; pass on unchanged + { $result[$field] = $value; continue; } @@ -311,7 +312,8 @@ function _set($tags, $force = false) { $expressions = $this->_expressions($tags, $force); $append = []; - foreach ((array)$expressions as $k => $v) { + foreach ((array)$expressions as $k => $v) + { if (is_int($k)) /* no key specified; just append */ $append[] = $v; else @@ -329,7 +331,8 @@ function _values($tags, $force = false) { $expressions = $this->_expressions($tags, $force); $append = []; - foreach ((array)$expressions as $k => $v) { + foreach ((array)$expressions as $k => $v) + { if (is_int($k)) /* no key specified; just append */ $append[] = $v; else { @@ -337,6 +340,7 @@ function _values($tags, $force = false) $vals[] = $v; } } + return $expressions ? '(' . implode(', ', $keys) . ') VALUES (' . implode(', ', $vals) . ')' . implode(' ', $append) : ''; } @@ -931,7 +935,8 @@ function _get_field_info() if (!($this->_fields = $state['fields'][$this->_p['table']])) { debug("it_dbi(): no fields for {$dbid}.{$this->_p['table']}, calculating.", 5); - foreach ($this->_get_field_defs() as $name => $field) { + foreach ($this->_get_field_defs() as $name => $field) + { $this->_fields[$name] = $field + array('Length' => preg_match('/date|time/', $field['Type']) ? 20 : intval(it::match('\d+', $field['Type']))); if (preg_match('/^(tiny|small|medium|)int|^float|^double/', $field['Type'])) $this->_convertfunc[$name] = it::match('int', $field['Type']) ? "intval" : "floatval"; |