2

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?

gmarintes
  • 1,288
  • 12
  • 16
  • did you ever figure this out? I'm having the exact same problem. – Anthony Mar 08 '16 at 18:11
  • Yes I did. See my answer. On my development environment, I disabled MySQL cache so I always get the Execute log. That made it easier for me to check what parameters were actually sent to MySQL. – gmarintes Mar 08 '16 at 20:49

2 Answers2

0

can you do this

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

Sorry, not enugh reps to comment. What's DD output?

TrueStory
  • 439
  • 5
  • 17
  • It prints the Eloquent object. However, that is not what I was looking for. I'm looking for the missing Execute login my MySQL log. – gmarintes Nov 03 '14 at 18:04
0

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.

gmarintes
  • 1,288
  • 12
  • 16