tomyeh/postgresql

implement the methods beginTransaction, commit , rollback like PHP PDO

insinfo opened this issue · 2 comments

implement the methods startTransaction , commit , rollback like PHP PDO

https://www.php.net/manual/pt_BR/pdo.commit.php
https://www.php.net/manual/pt_BR/pdo.begintransaction.php
https://www.php.net/manual/pt_BR/pdo.rollback

bool beginTransaction() {
    connection.execute('begin');
    
  }

  bool commit() {
     connection.execute('commit');
  }


  bool rollback() {
     connection.execute('rollback');
  }

Please use runInTransaction instead.

@tomyeh
I would like a way to do PDO-style transactions without closing, so I decided to create a driver from scratch, I'm working on a postgreSQL driver here: https://github.com/insinfo/pg8000

I was strongly inspired by a driver written in python but also by its implementation.

I verified that your "runInTransaction" implementation fails because there is no isolation for asynchronous accesses, that is, in a server side application receiving multiple asynchronous requests it mixes the transactions.