我有一个简单的存储过程:
PROCEDURE `status_recalculate`(IN aid INT)
BEGIN
DECLARE actions INT DEFAULT 0;
DECLARE rid INT DEFAULT 0;
DECLARE actions_done INT DEFAULT 0;
DECLARE status_done INT DEFAULT 0;
SELECT request_id INTO rid FROM mtset_dev.actions a WHERE a.id=aid;
SELECT count(*) INTO actions FROM mtset_dev.actions a WHERE a.request_id=rid;
SELECT count(*) INTO actions_done FROM mtset_dev.actions a WHERE a.request_id=rid AND a.action_status=1;
SELECT CEIL(actions_done/actions*100) INTO status_done;
#UPDATE requests SET `status` = status_done WHERE id=rid;
SELECT rid, status_done;
END
我想通过 AJAX 从 Kohana 3.2 调用它。在模型中有代码:
$query = "call status_recalculate($aid);";
DB::query(Database::SELECT, $query)->execute();
并且没有成功的 AJAX 响应。我究竟做错了什么?我怎样才能得到结果(或者,也许是错误)?阅读这个答案没有帮助。
谢谢。