beginDbTransaction() public method

Begins the transaction (and turns off auto-committing).
public beginDbTransaction ( )
示例#1
0
文件: Sql.php 项目: raz0rsdge/horde
 /**
  */
 public function write($id, $session_data)
 {
     if (!$this->_db->isActive()) {
         $this->_db->reconnect();
         $this->_db->beginDbTransaction();
     }
     /* Check if session exists. */
     try {
         $exists = $this->_db->selectValue(sprintf('SELECT 1 FROM %s WHERE session_id = ?', $this->_params['table']), array($id));
     } catch (Horde_Db_Exception $e) {
         return false;
     }
     /* Update or insert session data. */
     $session_data = new Horde_Db_Value_Binary($session_data);
     try {
         if ($exists) {
             $query = sprintf('UPDATE %s ' . 'SET session_data = ?, session_lastmodified = ? ' . 'WHERE session_id = ?', $this->_params['table']);
             $values = array($session_data, time(), $id);
             $this->_db->update($query, $values);
         } else {
             $query = sprintf('INSERT INTO %s ' . '(session_id, session_data, session_lastmodified) ' . 'VALUES (?, ?, ?)', $this->_params['table']);
             $values = array($id, $session_data, time());
             $this->_db->insert($query, $values);
         }
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         try {
             $this->_db->rollbackDbTransaction();
         } catch (Horde_Db_Exception $e) {
         }
         return false;
     }
     return true;
 }
示例#2
0
文件: Sql.php 项目: horde/horde
 /**
  */
 public function write($id, $session_data)
 {
     if (!$this->_db->isActive()) {
         $this->_db->reconnect();
         $this->_db->beginDbTransaction();
     }
     /* Check if session exists. */
     try {
         $exists = $this->_db->selectValue(sprintf('SELECT 1 FROM %s WHERE session_id = ?', $this->_params['table']), array($id));
     } catch (Horde_Db_Exception $e) {
         return false;
     }
     /* Update or insert session data. */
     $values = array('session_data' => new Horde_Db_Value_Binary($session_data), 'session_lastmodified' => time());
     try {
         if ($exists) {
             $this->_db->updateBlob($this->_params['table'], $values, array('session_id = ?', array($id)));
         } else {
             $this->_db->insertBlob($this->_params['table'], array_merge(array('session_id' => $id), $values));
         }
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         try {
             $this->_db->rollbackDbTransaction();
         } catch (Horde_Db_Exception $e) {
         }
         return false;
     }
     return true;
 }
示例#3
0
文件: Sql.php 项目: jubinpatel/horde
 /**
  * Removes a group.
  *
  * @param mixed $gid  A group ID.
  *
  * @throws Horde_Group_Exception
  */
 public function remove($gid)
 {
     try {
         $this->_db->beginDbTransaction();
         $this->_db->delete('DELETE FROM horde_groups_members WHERE group_uid = ?', array($gid));
         $this->_db->delete('DELETE FROM horde_groups WHERE group_uid = ?', array($gid));
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Group_Exception($e);
     }
 }
示例#4
0
文件: Sql.php 项目: jubinpatel/horde
 /**
  */
 public function removeAllVersions($pagename)
 {
     /* Remove attachments and do other cleanup. */
     parent::removeAllVersions($pagename);
     $this->_pageNames = null;
     try {
         $this->_db->beginDbTransaction();
         $this->_db->delete('DELETE FROM ' . $this->_params['table'] . ' WHERE page_name = ?', array($this->_convertToDriver($pagename)));
         $this->_db->delete('DELETE FROM ' . $this->_params['historytable'] . ' WHERE page_name = ?', array($this->_convertToDriver($pagename)));
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         $this->_db->rollbackDbTransaction();
         throw new Wicked_Exception($e);
     }
 }
示例#5
0
文件: Sql.php 项目: jubinpatel/horde
 /**
  */
 public function sort($rules)
 {
     $old = $this->_filters;
     parent::sort($rules);
     $query = sprintf('UPDATE %s SET rule_order = ? WHERE rule_id = ?', $this->_params['table_rules']);
     $this->_db->beginDbTransaction();
     try {
         foreach ($this->_filters as $key => $val) {
             $this->_db->update($query, array($key, $val['id']));
         }
     } catch (Horde_Db_Exception $e) {
         $this->_db->rollbackDbTransaction();
         $this->_filters = $old;
         throw new Ingo_Exception($e);
     }
     $this->_db->commitDbTransaction();
 }
示例#6
0
文件: SplitRead.php 项目: horde/horde
 /**
  * Begins the transaction (and turns off auto-committing).
  */
 public function beginDbTransaction()
 {
     $result = $this->_write->beginDbTransaction();
     $this->_lastQuery = $this->_write->getLastQuery();
     return $result;
 }