CodeIgniter Forums

Full Version: CI transaction on functions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Raymondddd[/eluser]
Hi guys,

Currently creating a cart system for a company with CI. In the last step of the checkout i call a lot of functions like; create user, create order, order detail and more.

I need to check if any of these function went ok, and if not; use a transaction.

I've read this: http://ellislab.com/codeigniter/user-gui...tions.html but this will only work if you create a list of DB queries between the trans_start and trans_complete.

Is there something like a transaction possibility using functions?

Looking forward to your reply.

Raymond

El Forum

[eluser]Kamarg[/eluser]
Maybe I don't understand the problem but it sounds like you just need to check the return value(s) of your functions. If one of them failed abort the rest the process and rollback the database.