Skip to content

Commit

Permalink
lastInsertId() from MySQL returns the new ID as a string instead of a…
Browse files Browse the repository at this point in the history
…n int which causes issues with the new API not sending an int where an int is expected.

as the autoincremented IDs in MySQL always will be of type int, we cast it after retrieving
  • Loading branch information
s3inlc committed Feb 13, 2024
1 parent a97071a commit e095b43
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/dba/AbstractModelFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function save($model) {
$stmt = $dbh->prepare($query);
$stmt->execute($vals);

$id = $dbh->lastInsertId();
$id = intval($dbh->lastInsertId());
if ($id != 0) {
$model->setId($id);
return $model;
Expand Down

0 comments on commit e095b43

Please sign in to comment.