mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-28 00:39:19 +01:00
using mysql's REPLACE syntax instead of doing first a select to determine if the column exists and then an update or insert accordingly
This commit is contained in:
parent
bbe871a450
commit
355beade2a
@ -970,9 +970,8 @@
|
|||||||
return "'" . $this->Link_ID->BlobEncode($value) . "'";
|
return "'" . $this->Link_ID->BlobEncode($value) . "'";
|
||||||
case 'I':
|
case 'I':
|
||||||
return $this->Link_ID->BlobEncode($value);
|
return $this->Link_ID->BlobEncode($value);
|
||||||
default:
|
|
||||||
break; // handled like strings
|
|
||||||
}
|
}
|
||||||
|
break; // handled like strings
|
||||||
case 'date':
|
case 'date':
|
||||||
return $this->Link_ID->DBDate($value);
|
return $this->Link_ID->DBDate($value);
|
||||||
case 'timestamp':
|
case 'timestamp':
|
||||||
@ -1139,6 +1138,7 @@
|
|||||||
$table_def = $this->get_table_definitions($app,$table);
|
$table_def = $this->get_table_definitions($app,$table);
|
||||||
|
|
||||||
$sql_append = '';
|
$sql_append = '';
|
||||||
|
$cmd = 'INSERT';
|
||||||
if (is_array($where) && count($where))
|
if (is_array($where) && count($where))
|
||||||
{
|
{
|
||||||
switch($this->Type)
|
switch($this->Type)
|
||||||
@ -1146,6 +1146,9 @@
|
|||||||
case 'sapdb': case 'maxdb':
|
case 'sapdb': case 'maxdb':
|
||||||
$sql_append = ' UPDATE DUPLICATES';
|
$sql_append = ' UPDATE DUPLICATES';
|
||||||
break;
|
break;
|
||||||
|
case 'mysql':
|
||||||
|
$cmd = 'REPLACE';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$this->select($table,'count(*)',$where,$line,$file);
|
$this->select($table,'count(*)',$where,$line,$file);
|
||||||
if ($this->next_record() && $this->f(0))
|
if ($this->next_record() && $this->f(0))
|
||||||
@ -1156,7 +1159,7 @@
|
|||||||
}
|
}
|
||||||
$data = array_merge($where,$data); // the checked values need to be inserted too, value in data has precedence
|
$data = array_merge($where,$data); // the checked values need to be inserted too, value in data has precedence
|
||||||
}
|
}
|
||||||
$sql = "INSERT INTO $table ".$this->column_data_implode(',',$data,'VALUES',False,$table_def['fd']).$sql_append;
|
$sql = "$cmd INTO $table ".$this->column_data_implode(',',$data,'VALUES',False,$table_def['fd']).$sql_append;
|
||||||
|
|
||||||
if ($this->Debug) echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app') sql='$sql'</p>\n";
|
if ($this->Debug) echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app') sql='$sql'</p>\n";
|
||||||
return $this->query($sql,$line,$file);
|
return $this->query($sql,$line,$file);
|
||||||
|
Loading…
Reference in New Issue
Block a user