/**
  * Commit everything inside this transaction so far
  */
 public function transactionEnd()
 {
     $result = sqlsrv_commit($this->dbConn);
     if (!$result) {
         $this->databaseError("Couldn't commit the transaction.");
     }
 }
 public function commitTransaction()
 {
     if ($this->transactionOn) {
         //$this->execute('COMMIT TRANSACTION');
         sqlsrv_commit($this->connection);
         $this->transactionOn = false;
     }
 }
 function trans_commit()
 {
     if (!$this->trans_enabled) {
         return TRUE;
     }
     // When transactions are nested we only begin/commit/rollback the outermost ones
     if ($this->_trans_depth > 0) {
         return TRUE;
     }
     return sqlsrv_commit($this->conn_id);
 }
Exemplo n.º 4
0
 /**
  * SQL Transaction
  * @access private
  */
 function _sql_transaction($status = 'begin')
 {
     switch ($status) {
         case 'begin':
             return sqlsrv_begin_transaction($this->db_connect_id);
             break;
         case 'commit':
             return sqlsrv_commit($this->db_connect_id);
             break;
         case 'rollback':
             return sqlsrv_rollback($this->db_connect_id);
             break;
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * 用于非自动提交状态下面的查询提交
  * @access public
  * @return boolean
  */
 public function commit()
 {
     if ($this->transTimes > 0) {
         $result = sqlsrv_commit($this->_linkID);
         $this->transTimes = 0;
         if (!$result) {
             $this->error();
             return false;
         }
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * Commit a transaction and return to autocommit mode.
  *
  * @return void
  * @throws Zend_Db_Adapter_Sqlsrv_Exception
  */
 protected function _commit()
 {
     if (!sqlsrv_commit($this->_connection)) {
         require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
         throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
     }
 }
Exemplo n.º 7
0
 public function commit_transaction()
 {
     sqlsrv_commit($this->connection);
 }
Exemplo n.º 8
0
 protected function _commit()
 {
     return sqlsrv_commit($this->handle);
 }
Exemplo n.º 9
0
 /**
  * @brief 커밋
  **/
 function commit($force = false)
 {
     if (!$force && ($this->is_connected == false || !$this->transaction_started)) {
         return;
     }
     $this->transaction_started = false;
     sqlsrv_commit($this->conn);
 }
 /**
  * Driver specific commit of real database transaction,
  * this can not be used directly in code.
  * @return void
  */
 protected function commit_transaction()
 {
     $this->query_start('native sqlsrv_commit', NULL, SQL_QUERY_AUX);
     $result = sqlsrv_commit($this->sqlsrv);
     $this->query_end($result);
 }
Exemplo n.º 11
0
 /*if ($notify_by_email)
   {
     require_once "functions_mail.inc";
     // Gather all fields values for use in emails.
     $mail_previous = get_booking_info($id, FALSE);
     // If this is an individual entry of a series then force the entry_type
     // to be a changed entry, so that when we create the iCalendar object we know that
     // we only want to delete the individual entry
     if (!$series && ($mail_previous['rep_type'] != REP_NONE))
     {
       $mail_previous['entry_type'] = ENTRY_RPT_CHANGED;
     }
   }*/
 sqlsrv_begin_transaction($conn);
 $start_times = mrbsDelEntry('test', $id, $series, 1);
 sqlsrv_commit($conn);
 // [At the moment MRBS does not inform the user if it was not able to delete
 // an entry, or, for a series, some entries in a series.  This could happen for
 // example if a booking policy is in force that prevents the deletion of entries
 // in the past.   It would be better to inform the user that the operation has
 // been unsuccessful or only partially successful]
 if ($start_times !== FALSE && count($start_times) > 0) {
     // Send a mail to the Administrator
     if ($notify_by_email) {
         // Now that we've finished with mrbsDelEntry, change the id so that it's
         // the repeat_id if we're looking at a series.   (This is a complete hack,
         // but brings us back into line with the rest of MRBS until the anomaly
         // of del_entry is fixed)
         if ($series) {
             $mail_previous['id'] = $mail_previous['repeat_id'];
         }
Exemplo n.º 12
0
 /**
  * Commits statements in a transaction.
  * @param  string  optional savepoint name
  * @return void
  * @throws Dibi\DriverException
  */
 public function commit($savepoint = NULL)
 {
     sqlsrv_commit($this->connection);
 }
Exemplo n.º 13
0
 /**
  * Commit a transaction and return to autocommit mode.
  *
  * @return void
  * @throws \Zend\Db\Adapter\SqlsrvException
  */
 protected function _commit()
 {
     if (!sqlsrv_commit($this->_connection)) {
         throw new SqlsrvException(sqlsrv_errors());
     }
 }
Exemplo n.º 14
0
 /**
  * Call this function to perform any of the following operation - INSERT, UPDATE, DELETE, READ
  * @param unknown $fieldValueArray - Associative Array
  * array(
  *				'Table'=> 'TableName',						//Mandatory
  *				'Fields'=> array(							//Mandatory
  *				'FieldName1' =>Value1,
  *				'FieldName2' =>Value2,
  *				'FieldName_n'=>Value_n
  *				)	
  *			)
  * @param unknown $operation - Type of operation : INSERT,UPDATE,DELETE,READ,INSERT_MR
  * @param unknown $outputFormat - Values possible : ASSOC | NUM_ARR | NUM_ROWS . Optional parameter
  */
 private function transact($fieldValueArray, $operation, $outputFormat = 'ASSOC')
 {
     $operation = strtoupper($operation);
     $transactReturnCode = -1;
     // Transaction Failed
     $read = false;
     switch ($operation) {
         case 'INSERT':
             $Query = $this->Prepare_Query($fieldValueArray, 'INSERT');
             break;
         case 'UPDATE':
             $Query = $this->Prepare_Query($fieldValueArray, 'UPDATE');
             break;
         case 'DELETE':
             $Query = $this->Prepare_Query($fieldValueArray, 'DELETE');
             break;
         case 'READ':
             $Query = $this->Prepare_Query($fieldValueArray, 'READ');
             $s = sqlsrv_query($this->dbconnection, $Query);
             $output = $this->Prepare_Output($s, $outputFormat);
             $transactReturnCode = $output;
             sqlsrv_free_stmt($s);
             $read = true;
             break;
         case 'INSERT_MR':
             $tableName = $fieldValueArray['TABLE_NAME'];
             $listOfID = $fieldValueArray['ID_LIST'];
             $FieldsArray = $fieldValueArray['FIELD_DETAILS'];
             $input_array = array('FIELD_ARRAY' => $FieldsArray, 'TABLE_NAME' => $tableName);
             $Query = $this->Prepare_Query($fieldValueArray, 'INSERT_MR');
             break;
     }
     if (!$read && sqlsrv_begin_transaction($this->dbconnection)) {
         $s = sqlsrv_query($this->dbconnection, $Query);
         if ($s) {
             sqlsrv_commit($this->dbconnection);
             $transactReturnCode = 0;
             // Transaction Success
         }
     }
     return $transactReturnCode;
 }
Exemplo n.º 15
0
 /**
  * Commits the sql transaction.
  *
  * @return boolean (Returns TRUE on success or FALSE on failure.)
  */
 function dbTransactionCommit()
 {
     return sqlsrv_commit(Database::getConnection());
     // Commits a transaction.
 }
Exemplo n.º 16
0
 /**
 +----------------------------------------------------------
 * 用于非自动提交状态下面的查询提交
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function commit()
 {
     if ($this->transTimes > 0) {
         $result = sqlsrv_commit($this->_linkID);
         $this->transTimes = 0;
         if (!$result) {
             throw_exception($this->error());
         }
     }
     return true;
 }
Exemplo n.º 17
0
 /**
  * End a transaction
  */
 protected function doCommit($fname = __METHOD__)
 {
     sqlsrv_commit($this->mConn);
     $this->mTrxLevel = 0;
 }
Exemplo n.º 18
0
 function commit_trans()
 {
     sqlsrv_commit($this->conn);
     $this->in_trans = false;
 }
Exemplo n.º 19
0
 /**
  * Commits started database transaction.
  *
  * @return void
  * @throws \Bitrix\Main\Db\SqlQueryException
  */
 public function commitTransaction()
 {
     $this->connectInternal();
     sqlsrv_commit($this->resource);
 }
Exemplo n.º 20
0
 /**
  * Commit a transaction
  *
  * @return void
  */
 public function commit()
 {
     return sqlsrv_commit($this->connection);
 }
Exemplo n.º 21
0
 /**
  * Commit
  */
 public function commit()
 {
     // http://msdn.microsoft.com/en-us/library/cc296194.aspx
     if (!$this->resource) {
         $this->connect();
     }
     $this->inTransaction = false;
     return sqlsrv_commit($this->resource);
 }
Exemplo n.º 22
0
 /**
  * DB transaction commit
  * this method is private
  * @return boolean
  */
 function _commit()
 {
     $connection = $this->_getConnection('master');
     sqlsrv_commit($connection);
     return true;
 }
Exemplo n.º 23
0
 /**
  * Commit the database changes done during a transaction that is in
  * progress or release a savepoint. This function may only be called when
  * auto-committing is disabled, otherwise it will fail. Therefore, a new
  * transaction is implicitly started after committing the pending changes.
  *
  * @param   string  name of a savepoint to release
  * @return  mixed   MDB2_OK on success, a MDB2 error on failure
  *
  * @access  public
  */
 function commit($savepoint = null)
 {
     $this->debug('Committing transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
     if (!$this->in_transaction) {
         return $this->raiseError(MDB2_ERROR_INVALID, null, null, 'commit/release savepoint cannot be done changes are auto committed', __FUNCTION__);
     }
     if (null !== $savepoint) {
         return MDB2_OK;
     }
     if (MDB2::isError(sqlsrv_commit($this->connection))) {
         return MDB2_ERROR;
     }
     $this->in_transaction = false;
     return MDB2_OK;
 }
Exemplo n.º 24
0
 /**
  * Commit Transaction
  *
  * @return	bool
  */
 protected function _trans_commit()
 {
     return sqlsrv_commit($this->conn_id);
 }
Exemplo n.º 25
0
 /**
  * {@inheritDoc}
  */
 public function commit()
 {
     if (!sqlsrv_commit($this->conn)) {
         throw SQLSrvException::fromSqlSrvErrors();
     }
 }
Exemplo n.º 26
0
 /**
  * End a transaction
  */
 function commit($fname = 'DatabaseMssql::commit')
 {
     sqlsrv_commit($this->mConn);
     $this->mTrxLevel = 0;
 }
Exemplo n.º 27
0
 function CommitTrans($ok = true)
 {
     if ($this->transOff) {
         return true;
     }
     if ($this->debug) {
         error_log('<hr>commit transaction');
     }
     if (!$ok) {
         return $this->RollbackTrans();
     }
     if ($this->transCnt) {
         $this->transCnt -= 1;
     }
     sqlsrv_commit($this->_connectionID);
     return true;
 }
Exemplo n.º 28
0
 /**
  * Makes sure each database and extension handles BEGIN, COMMIT and ROLLBACK 
  * 
  * @param  string|fStatement &$statement    The SQL to check for a transaction query
  * @param  string            $result_class  The type of result object to create
  * @return mixed  `FALSE` if normal processing should continue, otherwise an object of the type $result_class
  */
 private function handleTransactionQueries(&$statement, $result_class)
 {
     if (is_object($statement)) {
         $sql = $statement->getSQL();
     } else {
         $sql = $statement;
     }
     // SQL Server supports transactions, but the statements are slightly different.
     // For the interest of convenience, we do simple transaction right here.
     if ($this->type == 'mssql') {
         if (preg_match('#^\\s*(BEGIN|START(\\s+TRANSACTION)?)\\s*$#i', $sql)) {
             $statement = 'BEGIN TRANSACTION';
         } elseif (preg_match('#^\\s*SAVEPOINT\\s+("?\\w+"?)\\s*$#i', $sql, $match)) {
             $statement = 'SAVE TRANSACTION ' . $match[1];
         } elseif (preg_match('#^\\s*ROLLBACK\\s+TO\\s+SAVEPOINT\\s+("?\\w+"?)\\s*$#i', $sql, $match)) {
             $statement = 'ROLLBACK TRANSACTION ' . $match[1];
         }
     }
     $begin = FALSE;
     $commit = FALSE;
     $rollback = FALSE;
     // Track transactions since most databases don't support nesting
     if (preg_match('#^\\s*(BEGIN|START)(\\s+(TRAN|TRANSACTION|WORK))?\\s*$#iD', $sql)) {
         if ($this->inside_transaction) {
             throw new fProgrammerException('A transaction is already in progress');
         }
         $this->inside_transaction = TRUE;
         $begin = TRUE;
     } elseif (preg_match('#^\\s*COMMIT(\\s+(TRAN|TRANSACTION|WORK))?\\s*$#iD', $sql)) {
         if (!$this->inside_transaction) {
             throw new fProgrammerException('There is no transaction in progress');
         }
         $this->inside_transaction = FALSE;
         $commit = TRUE;
     } elseif (preg_match('#^\\s*ROLLBACK(\\s+(TRAN|TRANSACTION|WORK))?\\s*$#iD', $sql)) {
         if (!$this->inside_transaction) {
             throw new fProgrammerException('There is no transaction in progress');
         }
         $this->inside_transaction = FALSE;
         $rollback = TRUE;
         // MySQL needs to use this construct for starting transactions when using LOCK tables
     } elseif ($this->type == 'mysql' && preg_match('#^\\s*SET\\s+autocommit\\s*=\\s*(0|1)#i', $sql, $match)) {
         $this->inside_transaction = TRUE;
         if ($match[1] == '0') {
             $this->schema_info['mysql_autocommit'] = TRUE;
         } else {
             unset($this->schema_info['mysql_autocommit']);
         }
         // We have to track LOCK TABLES for MySQL because UNLOCK TABLES only implicitly commits if LOCK TABLES was used
     } elseif ($this->type == 'mysql' && preg_match('#^\\s*LOCK\\s+TABLES#i', $sql)) {
         // This command always implicitly commits
         $this->inside_transaction = FALSE;
         $this->schema_info['mysql_lock_tables'] = TRUE;
         // MySQL has complex handling of UNLOCK TABLES
     } elseif ($this->type == 'mysql' && preg_match('#^\\s*UNLOCK\\s+TABLES#i', $sql)) {
         // This command only implicitly commits if LOCK TABLES was used
         if (isset($this->schema_info['mysql_lock_tables'])) {
             $this->inside_transaction = FALSE;
         }
         unset($this->schema_info['mysql_lock_tables']);
         // These databases issue implicit commit commands when the following statements are run
     } elseif ($this->type == 'mysql' && preg_match('#^\\s*(ALTER|CREATE(?!\\s+TEMPORARY)|DROP|RENAME|TRUNCATE|LOAD|UNLOCK|GRANT|REVOKE|SET\\s+PASSWORD|CACHE|ANALYSE|CHECK|OPTIMIZE|REPAIR|FLUSH|RESET)\\b#i', $sql)) {
         $this->inside_transaction = FALSE;
     } elseif ($this->type == 'oracle' && preg_match('#^\\s*(CREATE|ALTER|DROP|TRUNCATE|GRANT|REVOKE|REPLACE|ANALYZE|AUDIT|COMMENT)\\b#i', $sql)) {
         $this->inside_transaction = FALSE;
     } elseif ($this->type == 'db2' && preg_match('#^\\s*CALL\\s+SYSPROC\\.ADMIN_CMD\\(\'REORG\\s+TABLE\\b#i', $sql)) {
         $this->inside_transaction = FALSE;
         // It appears PDO tracks the transactions, but doesn't know about implicit commits
         if ($this->extension == 'pdo') {
             $this->connection->commit();
         }
     }
     // If MySQL autocommit it set to 0 a new transaction is automatically started
     if (!empty($this->schema_info['mysql_autocommit'])) {
         $this->inside_transaction = TRUE;
     }
     if (!$begin && !$commit && !$rollback) {
         return FALSE;
     }
     // The PDO, OCI8 and SQLSRV extensions require special handling through methods and functions
     $is_pdo = $this->extension == 'pdo';
     $is_oci = $this->extension == 'oci8';
     $is_sqlsrv = $this->extension == 'sqlsrv';
     $is_ibm_db2 = $this->extension == 'ibm_db2';
     if (!$is_pdo && !$is_oci && !$is_sqlsrv && !$is_ibm_db2) {
         return FALSE;
     }
     $this->statement = $statement;
     // PDO seems to act weird if you try to start transactions through a normal query call
     if ($is_pdo) {
         try {
             $is_mssql = $this->type == 'mssql';
             $is_oracle = $this->type == 'oracle';
             if ($begin) {
                 // The SQL Server PDO object hasn't implemented transactions
                 if ($is_mssql) {
                     $this->connection->exec('BEGIN TRANSACTION');
                 } elseif ($is_oracle) {
                     $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
                 } else {
                     $this->connection->beginTransaction();
                 }
             } elseif ($commit) {
                 if ($is_mssql) {
                     $this->connection->exec('COMMIT');
                 } elseif ($is_oracle) {
                     $this->connection->exec('COMMIT');
                     $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, TRUE);
                 } else {
                     $this->connection->commit();
                 }
             } elseif ($rollback) {
                 if ($is_mssql) {
                     $this->connection->exec('ROLLBACK');
                 } elseif ($is_oracle) {
                     $this->connection->exec('ROLLBACK');
                     $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, TRUE);
                 } else {
                     $this->connection->rollBack();
                 }
             }
         } catch (Exception $e) {
             $db_type_map = array('db2' => 'DB2', 'mssql' => 'MSSQL', 'mysql' => 'MySQL', 'oracle' => 'Oracle', 'postgresql' => 'PostgreSQL', 'sqlite' => 'SQLite');
             throw new fSQLException('%1$s error (%2$s) in %3$s', $db_type_map[$this->type], $e->getMessage(), $sql);
         }
     } elseif ($is_oci) {
         if ($commit) {
             oci_commit($this->connection);
         } elseif ($rollback) {
             oci_rollback($this->connection);
         }
     } elseif ($is_sqlsrv) {
         if ($begin) {
             sqlsrv_begin_transaction($this->connection);
         } elseif ($commit) {
             sqlsrv_commit($this->connection);
         } elseif ($rollback) {
             sqlsrv_rollback($this->connection);
         }
     } elseif ($is_ibm_db2) {
         if ($begin) {
             db2_autocommit($this->connection, FALSE);
         } elseif ($commit) {
             db2_commit($this->connection);
             db2_autocommit($this->connection, TRUE);
         } elseif ($rollback) {
             db2_rollback($this->connection);
             db2_autocommit($this->connection, TRUE);
         }
     }
     if ($result_class) {
         $result = new $result_class($this);
         $result->setSQL($sql);
         $result->setResult(TRUE);
         return $result;
     }
     return TRUE;
 }
Exemplo n.º 29
0
 /**
  * Makes sure each database and extension handles BEGIN, COMMIT and ROLLBACK 
  * 
  * @param  string &$sql          The SQL to check for a transaction query
  * @param  string $result_class  The type of result object to create
  * @return mixed  `FALSE` if normal processing should continue, otherwise an object of the type $result_class
  */
 private function handleTransactionQueries(&$sql, $result_class)
 {
     // SQL Server supports transactions, but starts then with BEGIN TRANSACTION
     if ($this->type == 'mssql' && preg_match('#^\\s*(begin|start(\\s+transaction)?)\\s*#i', $sql)) {
         $sql = 'BEGIN TRANSACTION';
     }
     $begin = FALSE;
     $commit = FALSE;
     $rollback = FALSE;
     // Track transactions since most databases don't support nesting
     if (preg_match('#^\\s*(begin|start)(\\s+(transaction|work))?\\s*$#iD', $sql)) {
         if ($this->inside_transaction) {
             throw new fProgrammerException('A transaction is already in progress');
         }
         $this->inside_transaction = TRUE;
         $begin = TRUE;
     } elseif (preg_match('#^\\s*(commit)(\\s+(transaction|work))?\\s*$#iD', $sql)) {
         if (!$this->inside_transaction) {
             throw new fProgrammerException('There is no transaction in progress');
         }
         $this->inside_transaction = FALSE;
         $commit = TRUE;
     } elseif (preg_match('#^\\s*(rollback)(\\s+(transaction|work))?\\s*$#iD', $sql)) {
         if (!$this->inside_transaction) {
             throw new fProgrammerException('There is no transaction in progress');
         }
         $this->inside_transaction = FALSE;
         $rollback = TRUE;
     }
     if (!$begin && !$commit && !$rollback) {
         return FALSE;
     }
     // The PDO, OCI8 and SQLSRV extensions require special handling through methods and functions
     $is_pdo = $this->extension == 'pdo';
     $is_oci = $this->extension == 'oci8';
     $is_sqlsrv = $this->extension == 'sqlsrv';
     $is_ibm_db2 = $this->extension == 'ibm_db2';
     if (!$is_pdo && !$is_oci && !$is_sqlsrv && !$is_ibm_db2) {
         return FALSE;
     }
     $this->statement = $sql;
     // PDO seems to act weird if you try to start transactions through a normal query call
     if ($is_pdo) {
         try {
             $is_mssql = $this->type == 'mssql' && substr($this->database, 0, 4) != 'dsn:';
             $is_oracle = $this->type == 'oracle' && substr($this->database, 0, 4) != 'dsn:';
             if ($begin) {
                 // The SQL Server PDO object hasn't implemented transactions
                 if ($is_mssql) {
                     $this->connection->exec('BEGIN TRANSACTION');
                 } elseif ($is_oracle) {
                     $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
                 } else {
                     $this->connection->beginTransaction();
                 }
             } elseif ($commit) {
                 if ($is_mssql) {
                     $this->connection->exec('COMMIT');
                 } elseif ($is_oracle) {
                     $this->connection->exec('COMMIT');
                     $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, TRUE);
                 } else {
                     $this->connection->commit();
                 }
             } elseif ($rollback) {
                 if ($is_mssql) {
                     $this->connection->exec('ROLLBACK');
                 } elseif ($is_oracle) {
                     $this->connection->exec('ROLLBACK');
                     $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, TRUE);
                 } else {
                     $this->connection->rollBack();
                 }
             }
         } catch (Exception $e) {
             $db_type_map = array('db2' => 'DB2', 'mssql' => 'MSSQL', 'mysql' => 'MySQL', 'oracle' => 'Oracle', 'postgresql' => 'PostgreSQL', 'sqlite' => 'SQLite');
             throw new fSQLException('%1$s error (%2$s) in %3$s', $db_type_map[$this->type], $e->getMessage(), $sql);
         }
     } elseif ($is_oci) {
         if ($commit) {
             oci_commit($this->connection);
         } elseif ($rollback) {
             oci_rollback($this->connection);
         }
     } elseif ($is_sqlsrv) {
         if ($begin) {
             sqlsrv_begin_transaction($this->connection);
         } elseif ($commit) {
             sqlsrv_commit($this->connection);
         } elseif ($rollback) {
             sqlsrv_rollback($this->connection);
         }
     } elseif ($is_ibm_db2) {
         if ($begin) {
             db2_autocommit($this->connection, FALSE);
         } elseif ($commit) {
             db2_commit($this->connection);
             db2_autocommit($this->connection, TRUE);
         } elseif ($rollback) {
             db2_rollback($this->connection);
             db2_autocommit($this->connection, TRUE);
         }
     }
     if ($result_class) {
         $result = new $result_class($this);
         $result->setSQL($sql);
         $result->setResult(TRUE);
         return $result;
     }
     return TRUE;
 }
Exemplo n.º 30
0
 /**
  * Commit everything inside this transaction so far
  */
 public function transactionEnd()
 {
     if ($this->mssql) {
         DB::query('COMMIT TRANSACTION');
     } else {
         $result = sqlsrv_commit($this->dbConn);
         if (!$result) {
             $this->databaseError("Couldn't commit the transaction.", E_USER_ERROR);
         }
     }
 }