Showing posts with label Escape SQL. Show all posts
Showing posts with label Escape SQL. Show all posts

Saturday, March 11, 2017

Escape raw SQL queries in Laravel

Laravel is a strong php based framework today. Laravel has a strong query builder which handle escaping of SQL parameters. But sometimes we need to handle this situation ourselves. So we need to have the capability to handle this situation. We can do this easily using Laravel built-in function as below one line code:

DB::connection()->getPdo()->quote("TEXT 'TO" HANDLE");

Will output like:

'TEXT \'TO\" HANDLE' and MySQL will never mind with this.