我正在尝试选择数据库,并且设置了这样的日期
$endDate = new DateTime($fetch['loan_end']);
$endDate->add(new DateInterval('P5D'));
在这里执行:
$stmtBal = $controller->runQuery("SELECT SUM(amount)
FROM tbl_paid
WHERE pay_date <= :endDate
AND (c_id=:c_id AND (transaction_num=:transaction_num))");
$stmtBal->execute(array(":endDate" => $endDate,
":c_id" => $get_id,
":transaction_num" => $fetch['transaction_num']));
然后xampp给了我这个错误:
可恢复的致命错误:DateTime类的对象无法在.........等中转换为字符串
答案 0 :(得分:1)
尝试
$stmtBal->execute(array(":endDate"=>$fetch['loan_end'], ":c_id"=>$get_id, ":transaction_num"=>$fetch['transaction_num']));