雄辩的准备查询但不执行 [英] Eloquent prepares query but does not execute

查看:85
本文介绍了雄辩的准备查询但不执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个'客户'表,我想使用Laravel Eloquent使用客户的ID来获得记录:

  Customer :: where('customer_id','=',$ customer_id) - > get(); 

但是,当这个执行时,我检查MySQL日志,我得到:

 从`customer`中选择`kanji_name`,其中`customer_id` =? 
关闭stmt
退出

如您所见,没有'执行...。$ ...

我也尝试过:

 客户::找到($ CUSTOMER_ID); 

具有相同的结果。



任何人都知道为什么?

解决方案

似乎有一些形式的缓存发生在雄辩的一面或MySQL端(可能在MySQL端)。



我重新启动了我的MySQL服务器,发现在我第一次尝试,我得到

 从`customer`准备select *,其中`customer_id` =? 
从`customer`执行select *,其中`customer_id` ='4058'
关闭stmt
退出

在接下来的尝试中,我得到:

 从`customer`准备select * customer_id` =? 
关闭stmt
退出


I have a 'customer' table and I am trying to get a record using Laravel Eloquent using the customer's id:

Customer::where('customer_id', '=', $customer_id)->get();

However, when this gets executed I check the MySQL logs and I get:

Prepare select `kanji_name` from `customer` where `customer_id` = ?
Close stmt
Quit

As you can see, there is no 'Execute ...' log which should be present of the query was executed after preparing it.

I also tried:

Customer::find($customer_id);

with the same result.

Does anyone know the reason why?

解决方案

It seems there is some form of caching that is happening either on the Eloquent side or MySQL side (possibly on MySQL side).

I restarted my MySQL server and found that on my first try, I get

Prepare select * from `customer` where `customer_id` = ?
Execute select * from `customer` where `customer_id` = '4058'
Close stmt
Quit

While on succeeding tries, I get:

Prepare select * from `customer` where `customer_id` = ?
Close stmt
Quit

only.

这篇关于雄辩的准备查询但不执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆