DbObject: add deleteAll() method
This commit is contained in:
parent
5e7bdb1d3d
commit
b1c5878608
1 changed files with 25 additions and 0 deletions
|
@ -6,6 +6,7 @@ use EesyPHP\Hook;
|
||||||
use EesyPHP\Log;
|
use EesyPHP\Log;
|
||||||
|
|
||||||
use function EesyPHP\implode_with_keys;
|
use function EesyPHP\implode_with_keys;
|
||||||
|
use function EesyPHP\vardump;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property-read array<string,Attr> $_schema
|
* @property-read array<string,Attr> $_schema
|
||||||
|
@ -337,6 +338,30 @@ class DbObject {
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all matching objects
|
||||||
|
* @param array|string $where Where clauses as associative array of field name and value
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function deleteAll($where) {
|
||||||
|
if (!is_array($where) || empty($where)) {
|
||||||
|
Log :: warning(
|
||||||
|
"%s::deleteAll(): invalid where clauses provided (%s)",
|
||||||
|
get_called_class(), vardump($where)
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!static :: DB_CLASS :: delete(
|
||||||
|
static :: TABLE,
|
||||||
|
static :: _compute_where_clauses($where),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return False;
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List objects
|
* List objects
|
||||||
* @param array<string,mixed> $where Where clauses as associative array of field name and value
|
* @param array<string,mixed> $where Where clauses as associative array of field name and value
|
||||||
|
|
Loading…
Reference in a new issue