added 'async_' prefix to column-names of phpgw_async, as 'id' is a reserved word in sapdb

This commit is contained in:
Ralf Becker 2004-07-23 00:46:01 +00:00
parent d5c32df4e3
commit 29594f2771
4 changed files with 63 additions and 27 deletions

View File

@ -46,6 +46,7 @@
function asyncservice()
{
$this->db = $GLOBALS['phpgw']->db;
$this->db->set_app('phpgwapi');
$this->cronline = PHPGW_SERVER_ROOT . '/phpgwapi/cron/asyncservices.php '.$GLOBALS['phpgw_info']['user']['domain'];
@ -468,33 +469,33 @@
*/
function read($id=0)
{
$id = $this->db->db_addslashes($id);
if (strpos($id,'%') !== False || strpos($id,'_') !== False)
{
$where = "id LIKE '$id' AND id!='##last-check-run##'";
$id = $this->db->quote($id);
$where = "async_id LIKE $id AND async_id != '##last-check-run##'";
}
elseif (!$id)
{
$where = 'next<='.time()." AND id!='##last-check-run##'";
$where = 'async_next <= '.time()." AND async_id != '##last-check-run##'";
}
else
{
$where = "id='$id'";
$where = array('async_id' => $id);
}
$this->db->query($sql="SELECT * FROM $this->db_table WHERE $where",__LINE__,__FILE__);
$this->db->select($this->db_table,'*',$where,__LINE__,__FILE__);
$jobs = array();
while ($this->db->next_record())
{
$id = $this->db->f('id');
$id = $this->db->f('async_id');
$jobs[$id] = array(
'id' => $id,
'next' => $this->db->f('next'),
'times' => unserialize($this->db->f('times')),
'method' => $this->db->f('method'),
'data' => unserialize($this->db->f('data')),
'account_id' => $this->db->f('account_id')
'next' => $this->db->f('async_next'),
'times' => unserialize($this->db->f('async_times')),
'method' => $this->db->f('async_method'),
'data' => unserialize($this->db->f('async_data')),
'account_id' => $this->db->f('async_account_id')
);
//echo "job id='$id'<pre>"; print_r($jobs[$id]); echo "</pre>\n";
}
@ -519,15 +520,20 @@
$job['next'] = (int)$job['next'];
$job['account_id'] = (int)$job['account_id'];
if ($exists || $this->read($job['id']))
$data = array(
'async_next' => $job['next'],
'async_times' => serialize($job['times']),
'async_method' => $job['method'],
'async_data' => serialize($job['data']),
'async_accont_id' => $job['account_id'],
);
if ($exists)
{
$this->db->query("UPDATE $this->db_table SET next=$job[next],times='$job[times]',".
"method='$job[method]',data='$job[data]',account_id=$job[account_id] WHERE id='$job[id]'",__LINE__,__FILE__);
$this->db->update($this->db_table,$data,array('async_id' => $job['id']),__LINE__,__FILE__);
}
else
{
$this->db->query("INSERT INTO $this->db_table (id,next,times,method,data,account_id) VALUES ".
"('$job[id]',$job[next],'$job[times]','$job[method]','$job[data]',$job[account_id])",__LINE__,__FILE__);
$this->db->insert($this->db_table,$data,array('async_id' => $job['id']),__LINE__,__FILE__);
}
}
@ -538,7 +544,7 @@
*/
function delete($id)
{
$this->db->query("DELETE FROM $this->db_table WHERE id='$id'",__LINE__,__FILE__);
$this->db->delete($this->db_table,array('async_id' => $id),__LINE__,__FILE__);
return $this->db->affected_rows();
}

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'] = '1.0.0.001';
$setup_info['phpgwapi']['version'] = '1.0.1.001';
$setup_info['phpgwapi']['versions']['current_header'] = '1.27';
$setup_info['phpgwapi']['enable'] = 3;
$setup_info['phpgwapi']['app_order'] = 1;
@ -56,3 +56,4 @@

View File

@ -357,14 +357,14 @@
),
'phpgw_async' => array(
'fd' => array(
'id' => array('type' => 'varchar','precision' => '255','nullable' => False),
'next' => array('type' => 'int','precision' => '4','nullable' => False),
'times' => array('type' => 'varchar','precision' => '255','nullable' => False),
'method' => array('type' => 'varchar','precision' => '80','nullable' => False),
'data' => array('type' => 'text','nullable' => False),
'account_id' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0')
'async_id' => array('type' => 'varchar','precision' => '255','nullable' => False),
'async_next' => array('type' => 'int','precision' => '4','nullable' => False),
'async_times' => array('type' => 'varchar','precision' => '255','nullable' => False),
'async_method' => array('type' => 'varchar','precision' => '80','nullable' => False),
'async_data' => array('type' => 'text','nullable' => False),
'async_account_id' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0')
),
'pk' => array('id'),
'pk' => array('async_id'),
'fk' => array(),
'ix' => array(),
'uc' => array()

View File

@ -18,3 +18,32 @@
include('tables_update_0_9_12.inc.php');
include('tables_update_0_9_14.inc.php');
$test[] = '1.0.0.001';
function phpgwapi_upgrade1_0_0_001()
{
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','id','async_id');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','next','async_next');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','times','async_times');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','method','async_method');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','data','async_data');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','account_id','async_account_id');
$GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_async',array(
'fd' => array(
'async_id' => array('type' => 'varchar','precision' => '255','nullable' => False),
'async_next' => array('type' => 'int','precision' => '4','nullable' => False),
'async_times' => array('type' => 'varchar','precision' => '255','nullable' => False),
'async_method' => array('type' => 'varchar','precision' => '80','nullable' => False),
'async_data' => array('type' => 'text','nullable' => False),
'async_account_id' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0')
),
'pk' => array('async_id'),
'fk' => array(),
'ix' => array(),
'uc' => array()
));
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.001';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
?>