3

When you're writing native SQL statements with Doctrine, how are you supposed to escape input? In my experience, mysql_real_escape_string doesn't work.

Jason Swett
  • 43,526
  • 67
  • 220
  • 351

1 Answers1

3

When mysql_real_escape_string() is used properly it works great. Parameterized libraries like ADODB and PDO would not work without it. I strongly recommend using PDO.

rook
  • 66,304
  • 38
  • 162
  • 239
  • 13
    Since reading this I've discovered that `Doctrine_Manager::connection()` is a PDO instance, so if, for example, you have an instance of that called `$conn`, you can do `$conn->quote($value)`. – Jason Swett Dec 20 '10 at 19:06
  • Beware for the quote function! It does not escape the quotes like mysql_real_escape_string but returns the given data quoted, e.g. you call quote('check') and the return value is 'check' including single quotes. – 4thfloorstudios May 11 '15 at 11:42