php mysql where子句使用日期


php mysql where clause using Date

有谁能帮我一下吗?

$crDate = date("Y-m-d");
$sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId."AND crDate = ".$crDate;

我要做的是更新表"callrecord",其中crDate是当前日期。当我把And部分拿出来时,它工作得很好。

$sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId;

这个很好。但是我也想检查当前日期。任何帮助吗?

您可以使用MySQL函数curdate()而无需在php中计算。

$sql = "update callrecord set crEndtime = Now() 
        where crUsId = '$crUsId' AND crDate = curdate()";

我认为你应该尝试在$crDate周围使用单引号。