tareq1988 / wp-eloquent

Eloquent ORM for WordPress
https://tareq.co/2015/05/eloquent-orm-in-wordpress/
566 stars 135 forks source link

DB::commit() not saving changes to database #77

Open N00BEST opened 4 years ago

N00BEST commented 4 years ago

I'm making modifications to two tables in a given time and trying to avoid concurrency problems, so I'm using DB::beginTransaction();

Everything executes just fine, but when I do DB::commit() nothing changes in database. If I execute the exact same code without the transaction, everything goes just fine.

imagen

This is my code, I need to add the like to the liked_videos table and increase or decrease the likes/dislikes values on the videos table. If I run this exact code without the DB::commit() it works.

Working code: imagen

I also tried to use DB::transaction($callback) to achieve this, but didn't work either. My database is like this:

Initial State: liked_videos table imagen

videos table imagen

After not working code (with transaction and commit) it remains the same.

If executed without the beginTransaction and commit it updates the tables to this:

After working code State: liked_videos table imagen

videos table imagen

I've also tried to run the transaction directly on the database to check if the problem was on my MySql server, but it worked just fine.

I need some advice on see what could be wrong with this or which file I should check in order to submit a pull request with a possible solution.

Thanks in advance. Greetings

N00best.