
Originally Posted by
r937
almost every database server will throw a syntax error if you compare a numeric column value to a string
mysql will "silently" try to convert the string to a number (i.e. no error message, no warning message even), which leads to some unexpected results, like if you have
Code:
WHERE userid = '23skidoo'
obviously, if it's a character column, then you
must enclose the string in quotes
Code:
WHERE keyword = 'awesome'

Or just use PDO's prepared statements and the whole quote thingee goes away.
From the manual:
PHP Code:
/* Execute a prepared statement by passing an array of values */
$sql = 'SELECT name, colour, calories FROM fruit
WHERE calories < :calories AND colour = :colour';
$sth = $dbh->prepare($sql);
$red = $sth->fetchAll(array('calories' => 150, 'colour' => 'red'));
Bookmarks