Entity Insert Issue |
Greetings to all. I’m working on optimizing my code and have opted to implement the Entity class. However, I’m dealing with a ‘genres’ table and a ‘books_genres’ table. Below is the code I’m currently using:
PHP Code: namespace Library\Entities; When updating existing records, the process works fine. However, when attempting to add a new record, although the task completes, the ID is not generated in time, leading to a failure. Is there a solution to this issue, or must I generate the ID within the model or controller?
The id should be generated automatically but depending on how you create the file migration, this behavior depends on the file migration you create.
and then in your model set $useAutoIncrement to true as follows: PHP Code: protected $useAutoIncrement = true;
@xxxx[{::::::::::::::::::::::::::::::::>
|
Welcome Guest, Not a member yet? Register Sign In |