问题
I've exhausted all efforts at what appears to be a trivial problem, but gotten nowhere.
There is a simple Prepare statement:
$qry = $core->db->prepare("SELECT * FROM users WHERE email = '?'");
$qry->execute(array('email@address.com'));
However, no rows are returned. Running the query with the parameters hardcoded into the query results in a successful selection of one row. I've tryed many different methods of doing the prepare, but even it this most simple form it isn't working.
The PDO object is stored in a singleton called Core. PDO is using the mysql driver.
回答1:
Remove quotes from the query:
("SELECT * FROM users WHERE email = ?");
The reason to use placeholders (?
symbol) is to forget about quotes. PDO will add them automatically.
来源:https://stackoverflow.com/questions/2434560/pdo-prepare-statement-not-processing-parameters