0

I just want to know that Is it possible to reuse the connection that i already have? actually i am looking to save some temporary data before the final Commit. But i am not able to do that in PHP.

Here is some code:

class DBConfig {

  var $conn = "";

  public funciton __construct()
  {
     $this->conn = oci_connect('hr', 'welcome', 'localhost/XE');
  }

  public function save_temp_query($query) 
  {
        $result = oci_parse($this->conn, $query);
        $res    = oci_execute($result, OCI_NO_AUTO_COMMIT);             
        return $res;        
  }

  public function fetch_data($query) 
  {
    $result = null;
    if ($query) {
        $result = oci_parse($this->conn, $query);
        $r = oci_execute($result);
    }
    return $result;
  }

  public function save_commit_data()
  {
    return oci_commit($this->conn);
  }

}

Now you can see the $this->conn variable and its use this is how i am using this.

But every time i use this class then $this->conn refreshed every time and i'm also losing my temp data. and i have googled a lot.

May this is same question: Ensure php session gets the same oracle session when using oci_pconnect

But that's not my requirement. Please help!!

3
  • 1
    So you're basically looking for persistence in a stateless language...? Commented Aug 4, 2016 at 7:57
  • @Andrew - what you mean Stateless Language? Commented Aug 4, 2016 at 8:08
  • 1
    See here. Long story short, you won't be able to keep the connection alive without some black magic and virgin sacrifices. Joking aside, it's do-able but it won't be pretty or maintainable. Commented Aug 4, 2016 at 8:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.