Closed (works as designed)
Project:
Drupal core
Version:
6.4
Component:
database system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Sep 2008 at 16:18 UTC
Updated:
21 Jan 2009 at 00:23 UTC
to reproduce) call db_query with %s and single quote in the string
what happens) single quote replaced with two single quotes
what should happen) single quote replaced with backslash+single quote.
For mysql at least this is true. single quote s/b replaced with 2 single quotes. Instead it is replaced with backslash+quote. using mysql on both Linux and Windows and Drupal 6.4. Mysql version is 5.1.11.
Comments
Comment #1
pre911mindset commentedSorry I got this perfectly backwards. What I meant to say:
what should happen) single quote replaced with two single quotes
what happens ) single quote replaced with backslash+single quote.
Comment #2
phpdiva commentedI'm not a MySQL guru by any means, but I've never seen a single quote escaped by replacing it with two single quotes. I've always seen the backslash method.
From looking at the MySQL manual looks like both ways are acceptable.
Just from personal experience, backslash seems to be quite a bit more common. There might have been other reasons for selecting this method of escaping, but I'm sure this is by design.