Reputation: 133
$stmt = $dbh->prepare('INSERT INTO articles (author, subject, text, date,
special) VALUES (:author, :subject, :text, :date, :special)');
How should it look like when i need to add "special" value to database but "date is automatic and i dont need it in prepare statement.
Upvotes: 0
Views: 39
Reputation: 631
Make Your statement by omitting date
$stmt = $dbh->prepare('INSERT INTO articles (author, subject, text,
special) VALUES (:author, :subject, :text, :special)');
AND in database make date with type TIMESTAMP and default value = "CURRENT_TIMESTAMP".
Upvotes: 1
Reputation: 1191
An other option is to make date
with type TIMESTAMP and default value = "CURRENT_TIMESTAMP".
Consequently the database will do the work itself.
Upvotes: 0
Reputation: 157839
Well, just omit it
$stmt = $dbh->prepare('INSERT INTO articles (author, subject, text,
special) VALUES (:author, :subject, :text, :special)');
That's SQL syntax that has nothing to do with PDO and prepared statements.
If you don't want to prepare some value - just don't prepare it. That's all
Upvotes: 2