
mysticmoose04
Posts: 1
|
| Posted: 11/11/2008, 6:23 AM |
|
I'm redoing my inventory database with code charge and I've hit a road block. Here is what I want to do. I'm filling out a 'Purchase Order' form which asks for how many units you bought, date, and other misc info. What I want to do in code charge is when I put in that I bought 5 wingnuts, it adds +5 to my wingnut quantity count. I will note, there is an assumption that 'wingnuts' already exists. I am not trying to do anything really fancy.
I have the form all working, except the automatic inventory addition.
Here is the table diagram, they are related by the pro_id field.
[PurchaseOrder]
pur_ord_id
pur_ord_date
pur_qty_ordered
pur_total_cost
pro_id
[Product]
pro_id
pro_name
pro_qty
In my original php files.. I have it working by doing two separate sql commands. One command inserts the purchase order information while the other updates my product inventory count. Something along these lines: update product '$_post[pur_qty_ordered]' + [pro_qty]' etc etc. But I can't use that code with codecharge.
Any help would be appreciated,
Aaron
|
 |
 |
philipeph
Posts: 1
|
| Posted: 12/03/2008, 8:05 PM |
|
Hello,
You can also use ON-UPDATE and/or ON-INSERT database triggers on the database level so you don't have to do it your front-end code.
Philip E.
|
 |
 |
maxhugen
Posts: 272
|
| Posted: 12/04/2008, 7:04 PM |
|
If you cannot use Triggers (typically in hosted databases), you can use the AfterInsert, AfterUpdate and AfterDelete events to do the updating on your product table.
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
|

|
|
|
|