diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2009-01-22 12:48:13 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2009-01-22 12:48:13 +0000 |
commit | f245579adf90e41a0ccab2aba7d424cc45d16343 (patch) | |
tree | 7ae3c261b36d78c6b8838be65ab57a078262bf75 /phpBB/includes/db/db_tools.php | |
parent | 04fdca03b3761bdf24c2303bad3fcab35f5594a8 (diff) | |
download | forums-f245579adf90e41a0ccab2aba7d424cc45d16343.tar forums-f245579adf90e41a0ccab2aba7d424cc45d16343.tar.gz forums-f245579adf90e41a0ccab2aba7d424cc45d16343.tar.bz2 forums-f245579adf90e41a0ccab2aba7d424cc45d16343.tar.xz forums-f245579adf90e41a0ccab2aba7d424cc45d16343.zip |
adjust schema to support defining types of columns. This is required for dbms being very very strict.
git-svn-id: file:///svn/phpbb/trunk@9292 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db/db_tools.php')
-rw-r--r-- | phpBB/includes/db/db_tools.php | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index e57063534e..c246f85cb9 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -424,6 +424,25 @@ class phpbb_db_tools */ public function sql_insert_data($schema_data, &$data) { + // Go through the columns and define our type and column name for each column + $keys = $types = array(); + + foreach ($schema_data['columns'] as $column) + { + if (strpos($column, ':') === false) + { + $types[] = false; + $keys[] = $column; + continue; + } + + list($type, $column) = explode(':', $column, 2); + $types[] = $type; + $keys[] = $column; + } + + $size = sizeof($keys); + // Go through the data array... foreach ($schema_data['data'] as $key => $row) { @@ -432,12 +451,19 @@ class phpbb_db_tools { // Special case... $row[$_key] = $this->_sql_get_special_row($value, $data); + + if ($types[$_key] === false) + { + settype($row[$_key], gettype($row[$_key])); + } + else + { + settype($row[$_key], $types[$_key]); + } } // Build SQL array for INSERT - $sql_ary = array_combine(array_values($schema_data['columns']), $row); - $sql = 'INSERT INTO ' . $schema_data['table'] . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); - + $sql = 'INSERT INTO ' . $schema_data['table'] . ' ' . $this->db->sql_build_array('INSERT', array_combine($keys, $row)); $this->db->sql_query($sql); if (!empty($schema_data['store_auto_increment'])) |