0
我目前正在使用jqGrid php实现与手动事务在网格中添加记录。jqgrid php:如何报告对话框中的错误
例如为:
$oper = jqGridUtils::GetParam('oper');
if ($oper == 'add') {
$grid->trans = false; // disable the transaction
try {
jqGridDB::beginTransaction($conn);
$reference = jqGridUtils::GetParam('reference');
$name = jqGridUtils::GetParam('name');
$brand = jqGridUtils::GetParam('brand');
$price = jqGridUtils::GetParam('price');
$total_quantity_left = jqGridUtils::GetParam('total_quantity_left');
$product = jqGridDB::prepare($conn,
"INSERT INTO product (id, reference, name, brand, price, total_quantity_left) VALUES (NULL,?,?,?,?,?)",
array($reference,
$name,
$brand,
$price,
$total_quantity_left,
)
);
$stock1 = jqGridDB::prepare($conn,
"INSERT INTO stock (id, shop_id, product_id, quantity) SELECT NULL, 1, (SELECT MAX(id) FROM product), ?",
array(jqGridUtils::GetParam('quantity_shop1'))
);
$stock2 = jqGridDB::prepare($conn,
"INSERT INTO stock (id, shop_id, product_id, quantity) SELECT NULL, 2, (SELECT MAX(id) FROM product), ?",
array(jqGridUtils::GetParam('quantity_shop2'))
);
jqGridDB::execute($product);
jqGridDB::execute($stock1);
jqGridDB::execute($stock2);
jqGridDB::commit($conn);
} catch(Exception $e) {
jqGridDB::rollBack($conn);
echo $e->getMessage();
}
}
能正常工作至今。
我现在的问题是我想告诉用户在事务过程中是否发生错误:通常我想弹出一个显示$ e-> getMessage()的错误对话框,或者导致错误。由于在PHP级别检测到错误,我如何调用一个JavaScript代码部分来实现这个(alert(...)或$ .jqgrid.info_dialog(...)我猜)?
感谢,