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