CodeIgniter Forums
CI transaction on functions - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: CI transaction on functions (/thread-28624.html)



CI transaction on functions - El Forum - 03-17-2010

[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-guide/database/transactions.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


CI transaction on functions - El Forum - 03-17-2010

[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.