Using MySQL functions in PHP PDO prepared statements
问题 What's the right way of using a MySQL function while using PHP PDO? The function NOW() gets saved as a string instead of showing the time. $sth = $dbh->prepare("INSERT INTO pdo (namespace, count, teststring) VALUES (?, ?, ?)"); // these protect you from injection $sth->bindParam(1, $_a); $sth->bindParam(2, $_b); $sth->bindParam(3, $_c); $_a = 'Wishy-washy'; $_b = 123; $_c = 'NOW()'; // Doesn't work. Comes out as the string 'NOW()' (w/o the quotes) and not as a date 回答1: I would not pass