Update commonobject.class.php
This commit is contained in:
parent
af440b7c49
commit
d9ac7ab9da
@ -7892,35 +7892,37 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete cascade first
|
// Delete cascade first
|
||||||
if (!empty($this->childtablesoncascade)) {
|
if (is_array($this->childtablesoncascade)) {
|
||||||
foreach ($this->childtablesoncascade as $table)
|
foreach ($this->childtablesoncascade as $table)
|
||||||
{
|
{
|
||||||
$deleteFromObject=explode(':', $table);
|
$deleteFromObject = explode(':', $table);
|
||||||
if (count($deleteFromObject)>=2) {
|
if (count($deleteFromObject)>=2) {
|
||||||
$className=str_replace('@', '', $deleteFromObject[0]);
|
$className = str_replace('@', '', $deleteFromObject[0]);
|
||||||
$filePath=$deleteFromObject[1];
|
$filePath = $deleteFromObject[1];
|
||||||
$columnName=$deleteFromObject[2];
|
$columnName = $deleteFromObject[2];
|
||||||
if (dol_include_once($filePath)) {
|
if (dol_include_once($filePath)) {
|
||||||
$childObject = new $className($this->db);
|
$childObject = new $className($this->db);
|
||||||
if (is_callable($childObject, 'deleteByParentField')) {
|
if (method_exists($childObject, 'deleteByParentField')) {
|
||||||
$result = $childObject->deleteByParentField($this->id, $columnName);
|
$result = $childObject->deleteByParentField($this->id, $columnName);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
$this->errors[] = $childObject->error;
|
$this->errors[] = $childObject->error;
|
||||||
return -1;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->errors[] = 'Cannot find child class file ' .$filePath;
|
$error++;
|
||||||
return -1;
|
$this->errors[] = 'Cannot include child class file ' .$filePath;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $table . ' WHERE ' . $this->fk_element . ' = ' . $this->id;
|
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $table . ' WHERE ' . $this->fk_element . ' = ' . $this->id;
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
|
$error++;
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
$this->errors[] = $this->error;
|
$this->errors[] = $this->error;
|
||||||
$this->db->rollback();
|
break;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user