FIX : stickler
This commit is contained in:
parent
412746ec8f
commit
5ef681ef91
@ -9058,7 +9058,7 @@ abstract class CommonObject
|
||||
$columnName = $deleteFromObject[2];
|
||||
$TMoreSQL = array();
|
||||
$more_sql = $deleteFromObject[3];
|
||||
if(!empty($more_sql)) $TMoreSQL['customsql'] = $more_sql;
|
||||
if (!empty($more_sql)) $TMoreSQL['customsql'] = $more_sql;
|
||||
if (dol_include_once($filePath)) {
|
||||
$childObject = new $className($this->db);
|
||||
if (method_exists($childObject, 'deleteByParentField')) {
|
||||
@ -9144,10 +9144,12 @@ abstract class CommonObject
|
||||
*
|
||||
* @param int $parentId Parent Id
|
||||
* @param string $parentField Name of Foreign key parent column
|
||||
* @param array $filter an array filter
|
||||
* @param string $filtermode AND or OR
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteByParentField($parentId = 0, $parentField = '', $filter=array(), $filtermode="AND")
|
||||
public function deleteByParentField($parentId = 0, $parentField = '', $filter = array(), $filtermode = "AND")
|
||||
{
|
||||
global $user;
|
||||
|
||||
@ -9160,22 +9162,22 @@ abstract class CommonObject
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= " WHERE ".$parentField." = ".(int) $parentId;
|
||||
|
||||
// Manage filter
|
||||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
// Manage filters
|
||||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
if ($key == 'customsql') {
|
||||
$sqlwhere[] = $value;
|
||||
} elseif (strpos($value, '%') === false) {
|
||||
$sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')';
|
||||
} else {
|
||||
$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
|
||||
}
|
||||
$sqlwhere[] = $value;
|
||||
} elseif (strpos($value, '%') === false) {
|
||||
$sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')';
|
||||
} else {
|
||||
$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user