[英]Using DATE ADD with INSERT prepared statement
I'd like to know if its possible and/or sensible to use DATE_ADD with a prepared statement in PHP. 我想知道是否有可能和/或明智的在PHP中将DATE_ADD与已准备好的语句一起使用。 I have a number of variables I'm passing to PHP that I want to insert, one is a SQL format datetime and the other is the same datetime but I want to add a number of days to it.
我有许多要传递给PHP的变量要插入,一个是SQL格式的datetime,另一个是相同的datetime,但是我想增加一些天数。 The number of days is also held in a variable passed to PHP.. Here's my query so far
天数也保存在传递给PHP的变量中。这是到目前为止的查询
$mySql="INSERT INTO delay (delayBookID, delayEED0, delayEDD1, delayDDC, delayUserID, delayCreated)
VALUE (?,?,DATE_ADD(?,? DAY),?,?,NOW())";
to clarify: here my bind param 澄清一下:这是我的绑定参数
$stmt->bind_param('ssssss', $bookID, $edd0, $edd1, $xD4Book, $ddc, $userID);
Can anyone help?? 有人可以帮忙吗?
Thanks in advance 提前致谢
You can use DATE_ADD
in an INSERT statement, however, you are missing the key word INTERVAL in DATE_ADD
. 您可以在INSERT语句中使用
DATE_ADD
,但是,您缺少DATE_ADD
的关键字INTERVAL。
It should be DATE_ADD(?, INTERVAL ? DAY)
应该是
DATE_ADD(?, INTERVAL ? DAY)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.