mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-05 22:14:59 +02:00
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
This commit is contained in:
parent
04fdca03b3
commit
f245579adf
@ -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']))
|
||||
|
@ -130,6 +130,8 @@ class install_install extends module
|
||||
|
||||
include PHPBB_ROOT_PATH . 'common.' . PHP_EXT;
|
||||
|
||||
phpbb::$acm->purge();
|
||||
|
||||
$this->build_search_index($mode, $sub);
|
||||
$this->add_modules($mode, $sub);
|
||||
$this->add_language($mode, $sub);
|
||||
|
@ -47,7 +47,7 @@ $schema_data[] = array(
|
||||
// phpbb_config
|
||||
$schema_data[] = array(
|
||||
'table' => 'phpbb_config',
|
||||
'columns' => array('config_name', 'config_value'),
|
||||
'columns' => array('string:config_name', 'string:config_value'),
|
||||
'data' => array(
|
||||
array('active_sessions', '0'),
|
||||
array('allow_attachments', '1'),
|
||||
@ -311,7 +311,7 @@ $schema_data[] = array(
|
||||
// Dynamic config values
|
||||
$schema_data[] = array(
|
||||
'table' => 'phpbb_config',
|
||||
'columns' => array('config_name', 'config_value', 'is_dynamic'),
|
||||
'columns' => array('string:config_name', 'string:config_value', 'is_dynamic'),
|
||||
'data' => array(
|
||||
array('cache_last_gc', '0', 1),
|
||||
array('cron_lock', '0', 1),
|
||||
|
Loading…
x
Reference in New Issue
Block a user