Add phpgw_nextid table and common->nextid function

This commit is contained in:
Miles Lott 2001-03-22 08:23:35 +00:00
parent 3604032b53
commit db844b2ddb
6 changed files with 74 additions and 5 deletions

View File

@ -1258,4 +1258,34 @@
system("grep -r '^[ \t]*function' *");
echo '</pre>';
}
// This will return a value for the next id an app may need to insert values into ldap.
/*!
@function next_id
@abstract return the next higher value for an integer, and increment it in the db.
*/
function next_id($appname)
{
global $phpgw;
if (!$appname) {
return -1;
}
$phpgw->db->query("SELECT id FROM phpgw_nextid WHERE appname='".$appname."'");
while( $phpgw->db->next_record() ) {
$id = $phpgw->db->f("id");
}
if (empty($id) || !$id) {
$id = 1;
$phpgw->db->query("INSERT INTO phpgw_nextid (appname,id) VALUES ('".$appname."',".$id.")");
$phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'");
} else {
$id = $id + 1;
$phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'");
}
return intval($id);
}
}//end common class

View File

@ -336,7 +336,14 @@
);";
$phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre18';
$sql = "create table phpgw_nextid (
appname varchar(25),
id int(8),
UNIQUE (appname)
)";
$phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre19';
$phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi'];
update_version_table();
// $phpgw_setup->update_version_table();

View File

@ -1322,6 +1322,20 @@
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre18';
}
$test[] = '0.9.10pre18';
function upgrade0_9_10pre18() {
global $phpgw_info, $phpgw_setup;
$sql = "create table phpgw_nextid (
appname varchar(25),
id int(8),
UNIQUE (appname)
)";
$phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre19';
}
reset ($test);
while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -304,7 +304,13 @@
)";
$phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre18';
$sql = "create table phpgw_nextid (
appname varchar(25),
id int
)";
$phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre19';
$phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi'];
update_version_table();
?>

View File

@ -1570,6 +1570,18 @@
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre18';
}
$test[] = '0.9.10pre18';
function upgrade0_9_10pre18() {
global $phpgw_info, $phpgw_setup;
$sql = "create table phpgw_nextid (
appname varchar(25),
id int
)";
$phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre19';
}
reset ($test);
while (list ($key, $value) = each ($test)){

View File

@ -11,5 +11,5 @@
/* $Id$ */
$phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.10pre18";
$phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.10pre19";
$phpgw_info["server"]["versions"]["current_header"] = "1.11";