尝试调用以下存储过程,但获取警报读取“失败”。任何我可能会出错的想法。我是新手使用存储过程。
DROP PROCEDURE `datespop`//
CREATE DEFINER=`admin`@`localhost` PROCEDURE `datespop`( id int, startdate DATE, offweeks int, onweeks int, enddate date)
begin
set @currdate = startdate;
while @currdate < enddate do
set @endrotdate = date_add(@currdate, INTERVAL offweeks WEEK);
insert into rotation_blocks (start_date, end_date, user_id) values (@currdate, @endrotdate, id);
set @currdate = date_add(@endrotdate, INTERVAL onweeks WEEK);
end while;
end
$on = $_POST['on'];
$off = $_POST['off'];
$start_date = date('Y-m-d', strtotime($_POST['start_date']));
$end_date = date('Y-m-d', strtotime($_POST['end_date']));
$user_id = $_COOKIE["bk_id"];
try {
$stmt = $conn->prepare("CALL datespop($user_id, '$start_date', $on, $off, '$end_date')");
$stmt->execute();
} catch (PDOException $e) {
echo "<b>SQL Error #" . $e->getCode() . "</b> in <b>" . $e->getFile() . "</b> on line <b>" . $e->getLine() . ":</b> " . $e->getMessage() . "\n";
}