dongzaijiao4863 2017-06-27 00:21
浏览 43
已采纳

雄辩的查询错误

I am getting quite desperate with Laravel 5.4 and Eloquent Query builder. I am trying to retrieve a user by username and password.

I ve following columns in my db: ID, USERNAME, PASSWORD

Following query is working for me:

$user = UserModel::where(['username' => $username])->first();

while this one is not:

$user = UserModel::where(['password' => $password])->first();

I am printing out both $username and $password before the query, and both are exactly what they should be.

What can i possibly do wrong?

EDIT:

  • Yes I really do store password in plain text.
  • The method is a part of API based on Zend-xmlrpc-server
  • PHP does not return any error or exceptions
  • Xmlrpc server return "404 Unknown error" fault response.
  • Yes i am sure, that values do not contain any invisible characters and are indeed correct.
  • Values are hard coded in request, i also tried hard coding them directly in query with the same result.
  • I am using Oracle (11g I think), Laravel 5.4, PHP 5.6
  • Value pair is correct, this username belongs to this password and both are exactly in the same form as in database.

I tried following forms of queries with same results:

$user = UserModel::where('password', $password)->first();   
$user = UserModel::where(['password' => $password])->first();
$user = UserModel::where('password', '=', $password)->first(); 

Variations with username lead to exactly same results as in the first one mentioned.

  • 写回答

2条回答 默认 最新

  • drbhjey445647 2017-06-27 03:31
    关注

    Problem solved althought i am not exactly sure what caused it. Problem was, that Eloquent with oci8 driver (oracle driver) converts all column names to uppercase, but 'password' is some kind of reserved keyword and could not be converted and stayed in lowercase. While Oracle is case sensitive (for column and table names) it was not working. i changed name of 'password' column to 'passphrase' and everything worked immediately.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?