我有一些代碼,將記錄插入一個SQLite表:PHP PDO不會準備語句NOW()
$statement = $db -> prepare("INSERT INTO posts (postedOn, content, tags) VALUES (DATE('now'), :content, :tags)");
$statement -> bindParam(':content', $content);
$statement -> bindParam(':tags', $tags);
的問題是,postedOn列只獲得日期,而不是時間的帖子。我試着用NOW()代替:
$statement = $db -> prepare("INSERT INTO posts (postedOn, content, tags) VALUES (NOW(), :content, :tags)");
,但我得到
Call to a member function bindParam() on a non-object
第一bindParam電話。這工作正常,如果我在SQLite 2009 Pro中運行它:
INSERT INTO posts (postedOn, content, tags) VALUES (NOW(), 'some content', 'tags')
爲什麼不準備像NOW()?