Ad
Is There An Alternate Way To Use Findorfail() On Updating With Stored Procedures?
I'm getting an error :
"Call to undefined method Illuminate\Database\SqlServerConnection::find()"
I'm trying to update a table that was executed using stored procedure.
public function update(Request $request)
{
$cont = DB::find($request->ContainerId);
$cont->update($request->all());
return back();
}
I wanted to update a record in SQL Server but no luck at all.
Ad
Answer
DB
is in general an anti pattern in Laravel
applications and the DB
does not have a find
method either, it has methods for raw SQL
queries.
Instead utilize your model, use the static methods there (like find or findOrFail). The table name is generated from a pluralized version on the class name, so the table name should be containers
public class Container extends Model {
}
Container::find($request->ContainerId);
Ad
source: stackoverflow.com
Related Questions
- → How to make Laravel use my class instead of native PDO?
- → SQL: simple custom column in select doesn't work?
- → How to execute Stored Procedure from Laravel
- → Which database engine type should be specified for Microsoft SQL Database in Laravel?
- → How to troubleshoot PDOException?
- → laravel sql server stored procedure output
- → Issue with converting a date using Carbon
- → SQL microsoft query to Laravel 4.2
- → General error 20018 Cannot Continue the file execution because the session is in the Kill state
- → List names of all available MS SQL databases on server using python
- → Variable which replace DB of name in SSMS
- → Java: database connection. Where is my mistake?
- → How Can I use "Date" Datatype in sql server?
Ad