I am using PDO and prepared statements, but i cannot seem to get any results when comparing an ENUM field with an integer.
Example:
$db = new PDO('mysql:host=localhost;dbname=****', '***', '***');
$s = $db->prepare('SELECT id FROM t2 WHERE lang = ?');
$s->execute(array('en')); // Works
print_r($s->fetchAll());
$s->execute(array(2)); // Does not work
print_r($s->fetchAll());
I Am testing against this table:
DROP TABLE IF EXISTS t2;
CREATE TABLE t2 (
id int(10) NOT NULL AUTO_INCREMENT,
lang enum('no','en','fr') NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO t2 (id, lang) VALUES (NULL , 'en');
Any idea on how to get this to work?
I am converting to PDO, and I'd prefer not to rewrite all constants, enums, and queries in my app :(