mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 14:10:28 +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'");
|
$aeigenschaften = $this->app->DB->SelectArr("SELECT id FROM artikeleigenschaftenwerte WHERE artikel = '$id'");
|
||||||
if($aeigenschaften){
|
if($aeigenschaften){
|
||||||
foreach($aeigenschaften as $eigenschaft){
|
foreach($aeigenschaften as $eigenschaft){
|
||||||
$neue_eigenschaft = $this->app->DB->MysqlCopyRow("artikeleigenschaftenwerte", "id", $eigenschaft['id']);
|
$this->app->DB->MysqlCopyRow("artikeleigenschaftenwerte", "id", $eigenschaft['id'], Array('artikel' => $idnew));
|
||||||
$this->app->DB->Update("UPDATE artikeleigenschaftenwerte SET artikel = '$idnew' WHERE id = '$neue_eigenschaft' LIMIT 1");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1417,10 +1417,11 @@ class DB{
|
|||||||
* @param string $TableName
|
* @param string $TableName
|
||||||
* @param string $IDFieldName
|
* @param string $IDFieldName
|
||||||
* @param int $IDToDuplicate
|
* @param int $IDToDuplicate
|
||||||
|
* replace array('field' => 'value')
|
||||||
*
|
*
|
||||||
* @return int|null
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
public function MysqlCopyRow($TableName, $IDFieldName, $IDToDuplicate)
|
public function MysqlCopyRow($TableName, $IDFieldName, $IDToDuplicate, $replace = Array())
|
||||||
{
|
{
|
||||||
if(empty($TableName) || empty($IDFieldName) || empty($IDToDuplicate)) {
|
if(empty($TableName) || empty($IDFieldName) || empty($IDToDuplicate)) {
|
||||||
return null;
|
return null;
|
||||||
@ -1452,7 +1453,17 @@ class DB{
|
|||||||
$comma = "";
|
$comma = "";
|
||||||
foreach ($fields as $field => $value) {
|
foreach ($fields as $field => $value) {
|
||||||
if ($field != $IDFieldName) {
|
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 {
|
} else {
|
||||||
$sql .= "NULL";
|
$sql .= "NULL";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user