Can I use functions on insert or update? #709
-
I want to do something like the following in SQL Server.
I think you can use "WhereRaw" for "SELECT", but "Raw" cannot be used for INSERT. Please tell me how to use functions in "Insert" and "Update". |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello! To perform INSERT and UPDATE operations with specific functions in SQL Server, you can use the GETDATE() functions and other functions within SQL queries in Laravel
I assume you are using Eloquent and Laravel's Query Builder. If you are using a specific Eloquent model for your table, you can also use methods like create or update instead of DB::table. |
Beta Was this translation helpful? Give feedback.
-
You are looking for var query = new Query("MyTable").AsUpdate(new
{
Name = "The User",
Address = new UnsafeLiteral("@address")
}); |
Beta Was this translation helpful? Give feedback.
You are looking for
UnsafeLiteral
, this is similar to whatDB:raw
provide on Laravel.