I have some code that inserts a record into a SQLite table:
$statement = $db -> prepare("INSERT INTO posts (postedOn, content, tags) VALUES (DATE('now'), :content, :tags)");
$statement -> bindParam(':content', $content);
$statement -> bindParam(':tags', $tags);
The problem is that the postedOn column only gets the date, and not the time of the post. I tried using NOW() instead:
$statement = $db -> prepare("INSERT INTO posts (postedOn, content, tags) VALUES (NOW(), :content, :tags)");
but I get
Call to a member function bindParam() on a non-object
on the first bindParam call. This works fine if I run it in SQLite 2009 Pro:
INSERT INTO posts (postedOn, content, tags) VALUES (NOW(), 'some content', 'tags')
Why doesn’t prepare like NOW()?
http://www.sqlite.org/lang_datefunc.html
There is no
NOW()function in sqlite, try using'now'string indatetime(). SQLite 2009 Pro must have it’s own implementation of this function, that you can try to implement in php on your own: http://php.net/manual/en/pdo.sqlitecreatefunction.php