5 ms·
> The "write-raw-SQL-with-raw-strings" approach has one serious issue -- sql-injections. Nobody has advocated writing "raw SQL with raw strings" in years. The
by revvx 7y ago
> The "write-raw-SQL-with-raw-strings" approach has one serious issue -- sql-injections.
Nobody has advocated writing "raw SQL with raw strings" in years.
The valid way of using Raw SQL is using prepared statements and parametrized queries.
This method will protect you from SQL injection, will handle most issues with type/conversions and the queries are cacheable, so it's fast too.
Parametrization is handled by the database itself (not the specific driver), so it is battle tested.
https://stackoverflow.com/questions/8263371/how-can-prepared-statements-protect-from-sql-injection-attacks https://stackoverflow.com/questions/8263371/how-can-prepared...
- ordu 7y ago> Nobody has advocated writing "raw SQL with raw strings" in years. It is an overstatement. Every time I look into some random PHP code I see there raw SQL with raw strings. Maybe it is just me being "lucky"? By the way, the thread starter comment was mentioned it, I got phrase from it.
- philwelch 7y ago“Random PHP code” might be the operative phrase there.