I am pretty new to laravel and facing a problem building a query using CONCAT:
#From input
$password = $request->password;
#sql statement
UserMainTbl::where('username', '=', $username)->whereRaw('hashkey', '=', CONCAT('admin_id'.$password))
Table: UserMainTbl
Field: username, hashkey, admin_id
Got error:
Call to undefined function App\Http\Controllers\Auth\CONCAT()
------
Update:
I change my code and manage to stop the above error. But getting new error.
->where('hashkey', '=', DB::raw('concat(admin_id,"$password")'))
Column not found: 1054 Unknown column 'password123' in 'where clause' (SQL: select * from
user_main_tblwhereusername= xxx andhashkey= concat(admin_id,password123) limit 1)
------
Update [Solve]:
My bad on this one. It is just a simple string. Here is the solution for future reference, if any. Lol:
->where('hashkey', '=', DB::raw('concat(admin_id,"'.$password.'")'))
Can someone help to point how can I do it right?
Many thanks.
->where('hashkey', '=', DB::raw("concat(admin_id,'$password')"))