Comments (5)
would it be possible to paste here the actual/snippet of the transaction code?
On the other hand, based on examples, since you are using 2 connections, I think you should also make 2 transaction which depends on the other. Not sure though coz i haven't this scenario on actual.
Maybe try doing something like below:
[start db1 transaction]
[start db2 transaction]
[insert on db2]
[selec db1]
[insert db2]
[rollback if fails]
// default connection
DB::transaction(function($conn){
DB::connection('db2')->transaction(function($conn){
// do insert
// do select
// do insert
});
});
Way back, I think i stumbled to an issue on laravel framework with nested transactions but can't seem to find it anymore since issues are now closed on it's github site.
Hope this helps!
from laravel-oci8.
You can also try playing with the PDO object
try {
DB::connection()->getPdo()->beginTransaction();
// database queries here
DB::connection()->getPdo()->commit();
} catch (\PDOException $e) {
// Woopsy
DB::connection()->getPdo()->rollBack();
}
from laravel-oci8.
This is how I was trying to check the scenario, very basic, I'm gonna have some tests with your suggestions and let you know, thanks!
DB::transaction(function(){
//RO connection
//$company = Company::find(1);
$username = array(
'username' => 'alex.company'
);
//WO connection
User::create($username);
$company = Company::find(1);
$username = array(
//adding an error to rise an exception
'usermame' => 'tom.company',
);
//WO connection
User::create($username);
});
from laravel-oci8.
Tried different scenarios and it seems your suggestion works flawlessy, tnx! :)
I'm a bit puzzled since in fact the default connection is the one on which I wanted the rollback and the only one declared.
// default connection
DB::transaction(function($conn){
DB::connection('db2')->transaction(function($conn){
// do insert
// do select
// do insert
});
});
from laravel-oci8.
There seems to be no problem on your code but to be sure try enabling app.debug=true
so you can further see the error logs.
Anyways, good to hear that my suggestion works! Closing this issue now. :)
from laravel-oci8.
Related Issues (20)
- Materialized view HOT 2
- Case Sensitivity Issue with Alias Names HOT 2
- Improve pagination for newer oracle
- "sessionVars" config are ignored HOT 1
- Binding driver options are ignored when calling addBindingsToStatement method HOT 4
- OCI_DEFAULT Undefined HOT 2
- lock/lockForUpdate locks up all rows even combined with limit (Job Queue becomes unusable on large table) HOT 3
- Updating model with multiple blob columns fails
- DRCP Connection Pooling HOT 4
- Undefined type 'Yajra\Oci8\Oci8ServiceProvider'. HOT 5
- Method Yajra\Oci8\Schema\Grammars\OracleGrammar::compileColumns does not exist. HOT 2
- v10.4.3 introduced SQL error in SELECT FOR UPDATE HOT 4
- OracleProcessor.php function processColumns donot return key "auto_increment" HOT 2
- OCI_SUCCESS_WITH_INFO: ORA-28002: the password will expire within 13 days HOT 2
- Laravel 11 support is on the road? HOT 5
- [11.x] This database engine does not support inserting while ignoring errors.
- [11.x] Error Code : 942 Error Message : ORA-00942, Sessions table HOT 1
- Support PHP 8.3 With Laravel 10.x HOT 1
- Error LogicException This database driver does not support modifying columns HOT 1
- `Schema::dropIfExists()` not working in 11.2.2+ HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-oci8.