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 is possible to define in the database configuration. For example, I will define two identical settings, but with the 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 the collation
of the second connection configuration, just do so:
DB::connection('sqlserver-case-sensitive')->table('users')
->where('acc', $request->input('account'))
->where('pwd', $request->input('password'))
->first();
Recommended readings:
What is the coding/collation of the bank?
– Wallace Maxters
It’s Sql_latin1_general_cp1_ci_as. I tried to change it directly in the database, but it’s not accepting the collation exchange.
– Getulio
You know that Ci means case insensitive?
– Wallace Maxters
Yes. And this is exactly why I asked, to know if there is any way to determine this in the query of the proper Standard, since I could not change in the database, because there is a restriction.
– Getulio