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!!

Community
  • 1
  • 1
Shail Paras
  • 1,125
  • 1
  • 14
  • 34
  • 1
    So you're basically looking for persistence in a stateless language...? – Andrei Aug 04 '16 at 07:57
  • @Andrew - what you mean Stateless Language? – Shail Paras Aug 04 '16 at 08:08
  • 1
    See [here](http://stackoverflow.com/questions/6327243/is-php-or-php-based-web-framework-stateful-or-stateless). 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. – Andrei Aug 04 '16 at 08:13

0 Answers0