starting a transaction?

starting a transaction?

by Jelle Boomstra -
Number of replies: 2
Hello Forum,

If I want to update/add/change some records where it only makes sense if all changes go through, I guess I need some sort of transaction right?

Is there any way to do a transaction/rollback with moodle or the underlying adodb layer? I guess not because MySQL is used, but I am not sure. Any ideas would be welcome...
Average of ratings: -
In reply to Jelle Boomstra

Re: starting a transaction?

by Penny Leach -
Moodle has a couple functions available for this in lib/datalib.php, begin_sql and commit_sql which will detect if you're running on a db that supports transactions and send BEGIN and COMMIT.

You can run Moodle against Postgres and use these functions to get transactions going. Later Mysql has transactions but it's not supported by Moodle's begin_sql and commit_sql functions.
In reply to Penny Leach

Re: starting a transaction?

by Jelle Boomstra -
thanks Penny!

I am using Postgresql for that reason already. But it is not that important I guess. It's not like becaus eof the incorrect info in the db my customer is receiving twice the amount he ordered or something.

tried it, but i got some other error, so it is off again. First get the normal flow running correctly...