WARNING - changes preference_owner field to integer (was varchar(20)); also

found potential problem with 0.9.10 upgrade series re: db object usage
This commit is contained in:
Miles Lott 2002-05-19 22:52:34 +00:00
parent 30d51e6bf3
commit 1da1796bcb
3 changed files with 45 additions and 5 deletions

View File

@ -14,7 +14,7 @@
/* Basic information about this app */
$setup_info['phpgwapi']['name'] = 'phpgwapi';
$setup_info['phpgwapi']['title'] = 'phpgwapi';
$setup_info['phpgwapi']['version'] = '0.9.15.002';
$setup_info['phpgwapi']['version'] = '0.9.15.003';
$setup_info['phpgwapi']['versions']['current_header'] = '1.21';
$setup_info['phpgwapi']['enable'] = 3;
$setup_info['phpgwapi']['app_order'] = 1;

View File

@ -41,4 +41,41 @@
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.15.002';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '0.9.15.002';
function phpgwapi_upgrade0_9_15_002()
{
$GLOBALS['phpgw_setup']->oProc->CreateTable(
'phpgw_newprefs', array(
'fd' => array(
'preference_owner' => array('type' => 'int', 'precision' => 4, 'nullable' => False),
'preference_value' => array('type' => 'text')
),
'pk' => array('preference_owner'),
'fk' => array(),
'ix' => array(),
'uc' => array()
)
);
$GLOBALS['phpgw_setup']->oProc->query('SELECT * FROM phpgw_preferences',__LINE__,__FILE__);
$db2 = $GLOBALS['phpgw_setup']->db;
while($GLOBALS['phpgw_setup']->oProc->next_record())
{
$accountid = $GLOBALS['phpgw_setup']->oProc->f('preference_owner');
settype($accountid,'integer');
$db2->query('INSERT INTO phpgw_newprefs (preference_owner,preference_value) VALUES('
. $accountid . ",'"
. $GLOBALS['phpgw_setup']->oProc->f('preference_value') . "')",
__LINE__,__FILE__);
}
$GLOBALS['phpgw_setup']->oProc->DropTable('phpgw_preferences');
$GLOBALS['phpgw_setup']->oProc->RenameTable('phpgw_newprefs','phpgw_preferences');
$setup_info['phpgwapi']['currentver'] = '0.9.15.003';
return $setup_info['phpgwapi']['currentver'];
}
?>

View File

@ -78,7 +78,7 @@
{
global $setup_info, $phpgw_setup;
$db2 = $phpgw_setup->oProc;
$db2 = $phpgw_setup->db;
$phpgw_setup->oProc->query("SELECT account_groups,account_id FROM accounts",__LINE__,__FILE__);
if($phpgw_setup->oProc->num_rows())
@ -190,8 +190,8 @@
{
global $setup_info, $phpgw_setup;
$db2 = $phpgw_setup->oProc;
$db3 = $phpgw_setup->oProc;
$db2 = $phpgw_setup->db;
$db3 = $phpgw_setup->db;
$phpgw_setup->oProc->query("SELECT MAX(group_id) FROM groups",__LINE__,__FILE__);
$phpgw_setup->oProc->next_record();
@ -223,7 +223,10 @@
{
$new_group_id = mt_rand ($max_group_id, 60000);
$db2->query("SELECT account_id FROM phpgw_accounts WHERE account_id=$new_group_id",__LINE__,__FILE__);
if(!$db2->num_rows()) { break; }
if(!$db2->num_rows())
{
break;
}
}
$db2->query("SELECT account_lid FROM phpgw_accounts WHERE account_lid='$group_name'",__LINE__,__FILE__);
if($db2->num_rows())