Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use oci_new_connect instead oci_connect #137

Open
francescoparadisiniva opened this issue Mar 29, 2024 · 1 comment
Open

Use oci_new_connect instead oci_connect #137

francescoparadisiniva opened this issue Mar 29, 2024 · 1 comment

Comments

@francescoparadisiniva
Copy link

Hi everyone!

I have the following Code but it doesn't work.

DB::connection("oracle")->beginTransaction();
DB::connection("oracle_log")->beginTransaction();
dump(ModelExample::on("oracle")->count()); \\ 10 records
dump(ModelExample::on("oracle_log")->count()); \\ 10 records
ModelExample::on("oracle_log")->insert([
    "column" => "test"
]);
dump(ModelExample::on("oracle_log")->count()); \\ 11 records
dump(ModelExample::on("oracle")->count()); \\ I expect 10 records but i have 11 records

The oracle connection and oracle_log connection have the same configs.

Using the oci_connect function, as stated in the PHP documentation, oci_connect() with the same parameters will return the connection handle returned from the first call.
Using Laravel singletons for connections, there should be no problems with an increase in sessions.

My proposal would be to use the oci_new_connect function instead of oci_connect or use a parameter within the config on which function to use.

@yajra
Copy link
Owner

yajra commented Mar 30, 2024

Looks like a valid use case as defined in oci_new_connect. Maybe we use another config that will trigger this behavior?

Just a rough idea, maybe we can add a 'cached' => false config which will use oci_new_connect if set to false.

Feel free to submit a PR, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants