[英]This prepared statement Update query isn't working … why?
$query="UPDATE `db`.`tb` SET `colA` = ?, `colB` = ?, `colC` = ?, `colD` = ?, `colE` = ?, `colF` = ?, `colG` = ? WHERE `tb`.`colA` = ? AND month(date)= ?;";
$stmt = $web_dbi->prepare($query);
$stmt->bind_param("sssssssss", $colA_PHPvar, $colB_PHPvar, $colC_PHPvar, $colD_PHPvar, $colE_PHPvar, $colF_PHPvar, $colG_PHPvar, $colA_PHPvar, $colB_PHPvar);
$stmt->execute();
Additional information: 附加信息:
date
is the name of a column in db
. date
是db
列的名称。 tb
... tb
... AND month(date)= ?
AND month(date)= ?
时,此查询有效 from the Where clause and it's corresponding ?
?
variable ... figured it out ... I was passing a date variable via AJAX that was formatted as the numerical representation of the month (ie January=1 ...), and included the date
column as a column to update (formatted as a date in MySQL)(m-1-yyyy), when really I only needed the date
column in the Where clause (the numerical representation of month successfully matched month( date
) in database and updated other fields, and correctly format errored while updating date
( date
in database is simply the first of the month (m-1-yyyy)) (which can stay the same here) ... 弄清楚了...我正在通过AJAX传递一个日期变量,该日期变量的格式设置为月份的数字表示形式(即1月= 1 ...),并且将
date
列作为要更新的列(将其格式化为日期格式) MySQL)(m-1-yyyy),实际上我只需要Where子句中的date
列(month的数字表示形式成功匹配数据库中的month( date
)并更新了其他字段,并且在更新date
( date
正确格式化了错误在数据库中只是月份的第一天(m-1-yyyy)(此处可以保持不变)...
$query="UPDATE `db`.`tb` SET `colA` = ?, `colB` = ?, `colC` = ?, `colE` = ?, `colF` = ?, `colG` = ? WHERE `tb`.`colA` = ? AND month(date)= ?;";
$stmt = $web_dbi->prepare($query);
$stmt->bind_param("sssssssss", $colA_PHPvar, $colB_PHPvar, $colC_PHPvar, $colE_PHPvar, $colF_PHPvar, $colG_PHPvar, $colA_PHPvar, $colB_PHPvar);
$stmt->execute();
( colD
and $colD_PHPvar
were the date variable being passed via AJAX as a numerical representation of the month (ie January=1 ...) ... (
colD
和$colD_PHPvar
是通过AJAX传递的日期变量,以月份的数字表示(即1月= 1 ...)...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.