Question

Good Day,


Can anyone help me please on how to figure this one out.. Im creating a purchase order module on my project and this modules saves the data into 2 different tables at the same time, which are tblPurchaseOrder_order and tblProductList, but i need to get the purchase order id which will be generated automatically once the data is saved in the tblPurchaseOrder so that I can save it on the tblProductList as the reference id of the new products.

here's what my form looks like: enter image description here

my opinion is: I save first the data in tblPurchaseOrder then retrieve that id, then save the products on the tblProductList with the id I retrieved, would it be okay if i do that?

by the way im using laravel4

Your help would really be appreciated.. thank you for TIME :3 Best Regards.. -Melvn

Was it helpful?

Solution

Depending on your DB, once your first insert occurs it could be returning a value - the last inserted id. If so, you can use this in a join to get the purchase order id for your second insert.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top