jeudi 11 février 2016

Laravel Model get's wrong ID after saving

I've got a Laravel application (5.1.28) which I have running on a development server and production server.

dev: php 5.6.13 mysql 5.6.19

prod: php 5.6.16 mysql 5.5.27

mysql table: CREATE TABLE testquestions ( id bigint(20) UNSIGNED NOT NULL, testquestiongroup_id bigint(20) NOT NULL, description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, type varchar(255) COLLATE utf8_unicode_ci NOT NULL, created_at timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', updated_at timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

And the following php code; $question = new Question(); $question->testquestiongroup_id = $questiongroup->id; $question->save();

The code on my dev and prod environment are the same. Als the database content are the same, copied from prod to dev.

When I run this code my $question object will get a wrong ID back from mysql(?). When I check MySQL there is a new record with a (good) ID, but this ID isn't returned to my object. It get the same wrong ID over and over again. The wrong ID is from an object added 4 months ago.

This problem doesn't occur on my dev environment.

Is there some bug in MySQL or am I doing something wrong? Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire