A
A
Arthur2015-07-26 00:26:59
Laravel
Arthur, 2015-07-26 00:26:59

What is wrong in Laravel request code?

Hello.
There is a code

$code = 'TEXT'
DB::table('coupons')
->where('code', $code)
->select('coupons.active',  'coupons.created_at')
->toSql();

as a result I get a SQL query string like
select `coupons`.`active`, `coupons`.`created_at` from `coupons` where `code` = ?

for some reason, instead of a variable, the value of it is not substituted.
Maybe I'm doing something wrong?
Poke your nose into the error please)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
D', 2015-07-26
@astralo

Everything is correct. It uses PDO with placeholders ( prepared queries ).
Instead of ? TEXT will be substituted when the request goes to Mysql.

J
JhaoDa, 2015-07-26
@JhaoDa

Because it will be substituted by the mysql server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question