Oracle Laravel 4用户登录验证

Oracle Laravel 4用户登录验证,oracle,authentication,laravel,laravel-4,oracle-sqldeveloper,Oracle,Authentication,Laravel,Laravel 4,Oracle Sqldeveloper,我正在使用laravel和oracle数据库。现在,我正在制作登录部分。当我输入正确的用户名和密码,结果是好的。但我输入的用户名或密码不正确,出现以下异常: Illuminate \ Database \ QueryException oci_error() expects parameter 1 to be resource, object given (SQL: select * from test_laravel_auth where username = tugsuu and pass

我正在使用laravel和oracle数据库。现在,我正在制作登录部分。当我输入正确的用户名和密码,结果是好的。但我输入的用户名或密码不正确,出现以下异常:

Illuminate \ Database \ QueryException

oci_error() expects parameter 1 to be resource, object given (SQL: select * from test_laravel_auth where username = tugsuu and password = testsss)
我的控制器代码:

$user = DB::table('test_laravel_auth')->where('username', '=', $input['login_username'])
                                                    ->where('password', '=', $input['login_password'])
                                                    ->get();
            return count($user);
            if($user != null){
                return "SUCCESS :D";
            }
            return "failed";
试试这个

$user = DB::table('test_laravel_auth')->where('username', '=', Input::get('username'))
          ->where('password', '=', Input::get('password'))
          ->get();

    if(Auth::attempt($user)) 
    {
    //here success    
    }
    else
    {
     return Redirect::to('login')->with('login_errors','Invalid Login Credentials.');
    }

我建议您使用first而不是get(),这将检索第一条记录(只应找到一条)。您还可以尝试使用
firstOrFail()
,并在“失败”时创建一个错误处理程序。如果失败=登录不正确

$user = DB::table('test_laravel_auth')->where('username', '=', Input::get('login_username'))->where('password', '=', Input::get('login_password'))->first();

if (!is_null($user))
{
   Auth::login($user);
}
else
{
    //failed
}

我还在Laravel中使用Oracle数据库,此解决方案适合我:

if ( Auth::attempt( array( 'user_name' => Input::get( 'username' ), 'password' => Input::get( 'password' ) ) ) )
{
    return Redirect::intended( 'dashboard' );
}
else
{
    return Redirect::to( 'login' )->withInput( Input::except( 'password' ) );
}
我的代码与Laravel文档中的代码完全相同。它不要求您使用查询进行身份验证,您只需要使用Laravel附带的身份验证类

您使用的驱动程序/软件包是什么?我使用yajra/laravel-oci8软件包使Oracle与laravel协同工作。
您可以在其页面上阅读有关laravel-oci8软件包文档的更多信息:

我假设您使用的是[jfelder/laravel OracleDB]软件包。如现场所述,这是一个已知问题,并且已经添加了一个。尝试通过运行composer update来更新包


另一种选择是使用软件包连接到Oracle。

尝试您的解决方案。然后发生以下错误:Illumb\Database\QueryException oci\u error()期望参数1是给定的资源、对象(SQL:select*from test\u laravel\u auth,其中username=16,password=test)auth::trunt()接受数组,而不是对象,因此上述代码将无法工作。您需要使用Auth::login($user)从用户对象登录用户。或者,您可以使用Auth::loginUsingId(1)。$userData=array('username'=>11,'password'=>123);好的,Auth::attemps($userData)-这运行正常,但如果我插入的用户名存在于数据库中,则会发生以下其他失败异常:lluminate\Database\QueryException oci\u error()预期参数1是给定的资源对象(SQL:select*from test\u laravel\u Auth,其中用户名=16,密码=test)我的数据库中不存在16。请尝试上面的解决方案。