Skip to content

Commit

Permalink
Add return of number of rows affected to the query/execute methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksagona committed Sep 18, 2024
1 parent 62881b1 commit 480eac7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,9 @@ public static function findAll(?array $options = null, bool|array $toArray = fal
* @param mixed $sql
* @param array $params
* @param bool $toArray
* @return Collection|array|null
* @return Collection|array|int
*/
public static function execute(mixed $sql, array $params = [], bool|array $toArray = false): Collection|array|null
public static function execute(mixed $sql, array $params = [], bool|array $toArray = false): Collection|array|int
{
$record = new static();

Expand Down Expand Up @@ -458,7 +458,7 @@ public static function execute(mixed $sql, array $params = [], bool|array $toArr
$collection = new Record\Collection($rows);
return ($toArray !== false) ? $collection->toArray($toArray) : $collection;
} else {
return null;
return self::db()->getNumberOfAffectedRows();
}
}

Expand All @@ -467,9 +467,9 @@ public static function execute(mixed $sql, array $params = [], bool|array $toArr
*
* @param mixed $sql
* @param bool $toArray
* @return Collection|array|null
* @return Collection|array|int
*/
public static function query(mixed $sql, bool|array $toArray = false): Collection|array|null
public static function query(mixed $sql, bool|array $toArray = false): Collection|array|int
{
$record = new static();

Expand All @@ -494,7 +494,7 @@ public static function query(mixed $sql, bool|array $toArray = false): Collectio
$collection = new Record\Collection($rows);
return ($toArray !== false) ? $collection->toArray($toArray) : $collection;
} else {
return null;
return self::db()->getNumberOfAffectedRows();
}
}

Expand Down

0 comments on commit 480eac7

Please sign in to comment.