If it is complicated to compare passwords by SQL server, you can do it by PHP.
$result = DB::table('users')
->where('acc', $request->input('account'))
->first();
if ($result && $result->pwd === $request->input('password')) {
// Senhas conferem
}
Still, I think it's possible to define it in the database configuration. For example, I will set two equal settings, however with% collation
different.
[
'sqlserver' => [
'driver' => 'sqlsrv',
'host' => 'host',
'database' => '',
'username' => 'username',
'password' => 'password',
'prefix' => '',
'collation' => 'SQL_Latin1_General_CP1_CI_AS',
'charset' => 'latin1'
],
'sqlserver-case-sensitive' => [
'driver' => 'sqlsrv',
'host' => 'host',
'database' => '',
'username' => 'username',
'password' => 'password',
'prefix' => '',
'collation' => 'SQL_Latin1_General_CP1_CS_AS',
'charset' => 'latin1'
]
]
To use collation
of the second connection configuration, just do the following:
DB::connection('sqlserver-case-sensitive')->table('users')
->where('acc', $request->input('account'))
->where('pwd', $request->input('password'))
->first();
Recommended readings: