Tuesday, March 21, 2017

How to correct this simple Laravel DB query to put the where condition string parameter into the '' character?

I am pretty new in Laravel and I have the following problem.

Performing this simple update query:

$affected = DB::update('update pm_user set checked = 1 where email = ?', ['email' => $email]);

this generates this SQL query:

update pm_user set checked = 1 where email = my.email@gmail.com

that goes into error because the SQL query to perform have to be:

update pm_user set checked = 1 where email = 'my.email@gmail.com'

The email field is a string so have to be placed into ''

How can I modify my original PHP query to put the content of $email variable into the ''?



via Andrea Nobili

Advertisement