Forum
17:37
18/04/2011
Hello,
I'm currently using the jqGrid php implementation with a manual transaction for adding a record in the grid.
E.g.:
$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();
}
}
This works fine so far.
The problem that I have now is that I want to inform the user if an error occurred during the transaction: typically I'd like to popup a error dialog showing the $e->getMessage(), or the cause of the error
Since the error is detected at the php level, how do I invoke a javascript code portion to achieve this (alert(...) or $.jqgrid.info_dialog(...) I guess)?
Thanks,
jerome
Most Users Ever Online: 715
Currently Online:
52 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66