Re: PEAR::DB getting automcommit status

From: Date: Mon, 26 Sep 2005 09:48:58 +0000
Subject: Re: PEAR::DB getting automcommit status
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-39934@lists.php.net to get a copy of this message
Firman Wandayandi wrote:
On 9/26/05, Jeroen Houben <jeroen@terena.nl> wrote:
Hi, I think it useful to be able to get the current autocommit status of a PEAR::DB connection object. I can only use $db->autoCommit(false), but there is no method to get the autocommit property (marked as private) or to find out if a transaction was started. Any particular reason for this?
/**
    * enable automatic Commit
    *
    * @param boolean $onoff
    * @return mixed DB_Error
    *
    * @access public
    */
function autoCommit($onoff=false) {
       return $this->raiseError(DB_ERROR_NOT_CAPABLE);
} see autoCommit() is a public. Otherwise you right the autoCommit() returns DB_OK. Do you think like this: function autoCommit($onoff = null) {
    if ($onoff !== null) {
         $this->autocommit = $onoff;
    }
    return $this->autocommit;
} This looks a bit weird IMHO, you just get back whatever you pass in.
I think what I need is a simple getter for $autocommit: function getAutoCommit() { return $this->autocommit; } Jeroen

« previous php.pear.dev (#39934) next »