- Added a missing return from newly created items in save() ; also added a count in saveAll() method allowing to know how many items were saved
This commit is contained in:
1 parent
dc5e088551
commit
2210853093
2 files changed
+23
-9
No files matched your search
@@ -9,6 +9,8 @@ class PdoObject extends PDO {
|
||||
|
||||
public static ? string $dump = null;
|
||||
|
||||
public bool $executionStatus;
|
||||
|
||||
public function select(string $sql, array $parameters = []): PDOStatement
|
||||
{
|
||||
static::$dump && call_user_func_array(static::$dump, [ $sql, $parameters ]);
|
||||
@@ -29,7 +31,7 @@ class PdoObject extends PDO {
|
||||
public function runQuery(string $sql, array $parameters = []): ? PDOStatement
|
||||
{
|
||||
static::$dump && call_user_func_array(static::$dump, [ $sql, $parameters ]);
|
||||
# \debogueur([ $sql, $parameters ]);
|
||||
|
||||
try {
|
||||
if (false !== ( $statement = $this->prepare($sql) )) {
|
||||
return $this->execute($statement, $parameters, true);
|
||||
@@ -59,12 +61,16 @@ class PdoObject extends PDO {
|
||||
|
||||
public function execute(PDOStatement $statement, array $parameters = [], bool $commit = true): ? PDOStatement
|
||||
{
|
||||
$this->executionStatus = false;
|
||||
|
||||
try {
|
||||
if ( ! $this->inTransaction() ) {
|
||||
$this->beginTransaction();
|
||||
}
|
||||
|
||||
if (empty($parameters) ? $statement->execute() : $statement->execute($parameters)) {
|
||||
$this->executionStatus = empty($parameters) ? $statement->execute() : $statement->execute($parameters);
|
||||
|
||||
if ( $this->executionStatus ) {
|
||||
$statement->lastInsertId = $this->lastInsertId();
|
||||
|
||||
if ( $commit ) {
|
||||
@@ -79,7 +85,7 @@ class PdoObject extends PDO {
|
||||
}
|
||||
catch (\PDOException $e) {
|
||||
$this->rollback();
|
||||
|
||||
|
||||
throw $e;
|
||||
}
|
||||
catch (\Throwable $e) {
|
||||
|
||||
Reference in new issue
Block a user