Joke Collection Website - Blessing messages - What's the difference between laravel's firstOrCreate and firstOrNew?
What's the difference between laravel's firstOrCreate and firstOrNew?
After the data is not queried according to the conditions, FirstOrCreate sends the insert command back to the database to create a piece of data.
FirstOrNew does not really insert a new record into the database, but creates an eloquent object of the new record and returns it, and can control whether it is necessary to store the new object in the database.
Simply put, firstOrCreate is equivalent to firstOrNew first, and then saving the returned object to the database.
- Related articles
- What does it mean that some women pay a great price for their children online?
- Tomorrow is the Dragon Boat Festival. How to send text messages seems to be my own idea.
- Warm Tips for Safety in Rainy Days _ Tips for Safety in Rainy Days (2)
- How to cancel the repayment of provident fund loans?
- How to shoot hide-and-seek 2
- Knowledge and stories about poetry
- How to delete imessage information from other devices
- When the leader says to you, "Do it if you can, or leave if you can't", how should I answer?
- How many days does it take to express from Tangshan to Suizhong?
- Netease has been changing ties for 24 hours. Why hasn't there been any news yet?