Support the ongoing development of Laravel.io →
Configuration Database Eloquent
Last updated 2 years ago.
0

It wouldn't surprise me that it is a bug, or something that is non-supported, that is a rather large jump in mysql versions.

It would be time consuming but perhaps making a vm with that db version installed then testing it to confirm the error occurs. I would say download a older version of homestead, but the one thing taylor didn't do (or at least I cannot find) is keep a real version history for services that are in each version of homestead.

Maybe, if possible update the production version of mysql.

0

I checked the oldest homestead I have currently is 0.2.7, it has MySQL version 5.6.19

0

The problem get keeping weirder!

I tried the following code after inserting my code ($question->save())

var_dump($question);  
var_dump(\DB::getPdo()->lastInsertId());  

My question object gives a different ID ($question->id) than \DB::getPdo()->lastInsertId(). The returned ID from the $question object stays the wrong ID. The lastInsertId function returns the right ID.

Does it matter that the field is a BIGINT(20) ?

Last updated 8 years ago.
0

when you say different how different? what does it give you and what are you expecting?

Also bigint(20) doesnt matter.

one thing i cannot see in your create table is that id bigint(20) UNSIGNED NOT NULL, is NOT AN AUTO INCREMENT FIELD.. so in your model you should put a property like protected $autoincemrents = false (google, see the docs / open eloquent builder for the RIGHT syntax)

0

It is Auto increment, I don't know why the table dump didn't add it.

  • The save function ($question->save()) of the model did add a new record to the database. As expected with as an example: ID=1337, So when I call $question->id after saving I would expect 1337.
  • After the save function I do echo $question->id and I will get ID=666
  • But when I call DB::getPdo()->lastInsertId() after saving then I will get ID=1337.

Even when I do a loop where I save the question 4 times, every $question->id will be 666.

0

its probably the devil playing with you :p...

have you coded 666 in somewhere? maybe there is a getIdAttribute()? that hardcodes this to 666? can we see your model?

have you tried other methods such as findorcreate() see what that does? also do php artisan tinker and check in there?

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.