Velliz / pukoframework

Framework for quick PHP WEB, API and Console App development *scaffolds and generators included.
https://pukoframework.github.io
MIT License
12 stars 1 forks source link

Transactional for RDBMS #11

Open Velliz opened 3 years ago

Velliz commented 3 years ago

Until now, pukoframework don't have transactional feature, so i decided to add this function in next release into the PDA section on this framework.

Usage demonstration in my head so far,,, archived in 3 different way:

$transaction = DBI::Transactional('primary');

$x = new obj();
...
$x->save($transaction);
...
$y->modify($transaction);
...

$transaction->commit();
$transaction->cancel();
$pk = 'id';
$data = [...];
$id = [...];

DBI::Prepare('users', 'primary')->Save($data, $pk, $transaction);
DBI::Prepare('users', 'primary')->Update($id, $data, $transaction);
DBI::Prepare('users', 'primary')->Delete($id, $transaction);

$transaction->commit();
//or
$transaction->cancel();
$result = DBI::Transactional('primary', function($DBI) {

   $x = new obj();
   ...
   $x->save($DBI);
   ...
   $y->modify($DBI);
   ...

});

A lot of works happens in DBI class. Witch i must move out the $dbi instance out. So the object is being reusable in the transaction lifecycle.

Let's see if there was a progress in here.

Velliz commented 3 years ago

As mentioned in commits 165a0f8 the transactional achieved with DBI Function Component and will be shipped in next release.