Forums
This topic is locked
PHP/MySQL triggers, stored functions or procedures
Posted 13 Jul 2007 09:48:06
1
has voted
13 Jul 2007 09:48:06 Steve Fuller posted:
Howdy all,Has anyone had any luck with triggers in mysql 5? I have built a cart using DW8/php/mysql and my means for updating the subtotal for each line item is giving me fits. The easiest solution would be to have a mysql trigger fire off a sql statement for one table when another record gets interted into a different table. This is why I am having fits! My cart table contains the product info itself as well as a count column for a number of options available to this product via another table. This is the formula:
<pre id=code><font face=courier size=2 id=code>
"item option count" * "price per option" + "item price" * "quantity"
</font id=code></pre id=code>
But when hand coding this, I have run into issues with the order in which this is accomplished. First the item is added to the cart, then redirected to a page where they can choose a number of options. Once options are chosen, they can add another product or checkout from the cart display page.
From my perspective, a mysql trigger, stored function or procedure could really simplify this. Any help would be much appreciated!