dongzaijiao4863 2017-06-27 08: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 11: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条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?