mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-24 13:40:29 +01:00
Bugfix copy article with properties constraint error
This commit is contained in:
parent
a93dd971eb
commit
eef6eedb0b
@ -104,8 +104,7 @@ class ArticleService
|
||||
$aeigenschaften = $this->app->DB->SelectArr("SELECT id FROM artikeleigenschaftenwerte WHERE artikel = '$id'");
|
||||
if($aeigenschaften){
|
||||
foreach($aeigenschaften as $eigenschaft){
|
||||
$neue_eigenschaft = $this->app->DB->MysqlCopyRow("artikeleigenschaftenwerte", "id", $eigenschaft['id']);
|
||||
$this->app->DB->Update("UPDATE artikeleigenschaftenwerte SET artikel = '$idnew' WHERE id = '$neue_eigenschaft' LIMIT 1");
|
||||
$this->app->DB->MysqlCopyRow("artikeleigenschaftenwerte", "id", $eigenschaft['id'], Array('artikel' => $idnew));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,4 +128,4 @@ class ArticleService
|
||||
|
||||
return $idnew;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1417,10 +1417,11 @@ class DB{
|
||||
* @param string $TableName
|
||||
* @param string $IDFieldName
|
||||
* @param int $IDToDuplicate
|
||||
* replace array('field' => 'value')
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function MysqlCopyRow($TableName, $IDFieldName, $IDToDuplicate)
|
||||
public function MysqlCopyRow($TableName, $IDFieldName, $IDToDuplicate, $replace = Array())
|
||||
{
|
||||
if(empty($TableName) || empty($IDFieldName) || empty($IDToDuplicate)) {
|
||||
return null;
|
||||
@ -1452,7 +1453,17 @@ class DB{
|
||||
$comma = "";
|
||||
foreach ($fields as $field => $value) {
|
||||
if ($field != $IDFieldName) {
|
||||
$sql .= $comma."`".$field."`";
|
||||
$replaced = false;
|
||||
foreach ($replace as $rkey => $rvalue) {
|
||||
if ($field == $rkey) {
|
||||
$sql .= $comma."'".$rvalue."' AS `".$rkey."`";
|
||||
$replaced = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$replaced) {
|
||||
$sql .= $comma."`".$field."`";
|
||||
}
|
||||
} else {
|
||||
$sql .= "NULL";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user