How does one go about escaping parameters passed to a raw query in Laravel 4? I expected something like DB::escape()
(which rings a bell from Laravel 3) and als
Two answers here, that I use, have less verbose solutions built into the DB
facade.
First, value quoting:
// From linked answer
DB::connection()->getPdo()->quote("string to quote");
// In the DB facade
DB::getPdo()->quote('string to quote');
Second, identifier quoting (table and column names):
// From linked answer
DB::table('x')->getGrammar()->wrap('table.column');
// In the DB facade
DB::getQueryGrammar()->wrap('table.column');