本文整理汇总了PHP中sqlsrv_begin_transaction函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlsrv_begin_transaction函数的具体用法?PHP sqlsrv_begin_transaction怎么用?PHP sqlsrv_begin_transaction使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlsrv_begin_transaction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: begin_trans
function begin_trans()
{
if (sqlsrv_begin_transaction($this->conn) == false) {
echo "Could not begin transaction.\n";
die(print_r(sqlsrv_errors(), true));
}
$this->in_trans = true;
}
示例2: begin_transaction
public function begin_transaction()
{
sqlsrv_begin_transaction($this->connection);
}
示例3: trans_begin
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
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;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = $test_mode === TRUE ? TRUE : FALSE;
return sqlsrv_begin_transaction($this->conn_id);
}
示例4: trans_begin
function trans_begin($test_mode = FALSE)
{
if (!$this->trans_enabled) {
return TRUE;
}
if ($this->_trans_depth > 0) {
return TRUE;
}
$this->_trans_failure = $test_mode === TRUE ? TRUE : FALSE;
return sqlsrv_begin_transaction($this->conn_id);
}
示例5: begin_transaction
/**
* This function begins a transaction.
*
* @access public
* @override
* @throws Throwable_SQL_Exception indicates that the executed
* statement failed
*
* @see http://msdn.microsoft.com/en-us/library/ms188929.aspx
* @see http://php.net/manual/en/function.sqlsrv-begin-transaction.php
*/
public function begin_transaction()
{
if (!$this->is_connected()) {
throw new Throwable_SQL_Exception('Message: Failed to begin SQL transaction. Reason: Unable to find connection.');
}
$command = @sqlsrv_begin_transaction($this->resource);
if ($command === FALSE) {
$errors = @sqlsrv_errors(SQLSRV_ERR_ALL);
$reason = (is_array($errors) and isset($errors[0]['message'])) ? $errors[0]['message'] : 'Unable to perform command.';
throw new Throwable_SQL_Exception('Message: Failed to begin the transaction. Reason: :reason', array(':reason' => $reason));
}
$this->sql = 'BEGIN TRAN;';
}
示例6: _sql_transaction
/**
* 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;
}
示例7: startTransaction
/**
* Starts new database transaction.
*
* @return void
* @throws \Bitrix\Main\Db\SqlQueryException
*/
public function startTransaction()
{
$this->connectInternal();
sqlsrv_begin_transaction($this->resource);
}
示例8: begin_transaction
/**
* Driver specific start of real database transaction,
* this can not be used directly in code.
* @return void
*/
protected function begin_transaction()
{
// Recordsets do not work well with transactions in SQL Server,
// let's prefetch the recordsets to memory to work around these problems.
foreach ($this->recordsets as $rs) {
$rs->transaction_starts();
}
$this->query_start('native sqlsrv_begin_transaction', NULL, SQL_QUERY_AUX);
$result = sqlsrv_begin_transaction($this->sqlsrv);
$this->query_end($result);
}
示例9: doBegin
/**
* Begin a transaction, committing any previously open transaction
*/
protected function doBegin($fname = __METHOD__)
{
sqlsrv_begin_transaction($this->mConn);
$this->mTrxLevel = 1;
}
示例10: handleTransactionQueries
//.........这里部分代码省略.........
}
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;
}
示例11: verifyGenericQueryRollback
/**
* Execute data manipulation statement, then roll it back
* @param $type
* @param $table
* @param $query
* @return string
*/
protected function verifyGenericQueryRollback($type, $table, $query)
{
$this->log->debug("verifying {$type} statement");
if (!sqlsrv_begin_transaction($this->database)) {
return "Failed to create transaction";
}
$this->query($query, false);
$error = $this->lastError();
sqlsrv_rollback($this->database);
return $error;
}
示例12: _start_trans
protected function _start_trans()
{
return sqlsrv_begin_transaction($this->handle) ? true : false;
}
示例13: beginTransaction
/**
* Start a transaction or set a savepoint.
*
* @param string name of a savepoint to set
* @return mixed MDB2_OK on success, a MDB2 error on failure
*
* @access public
*/
function beginTransaction($savepoint = null)
{
$this->debug('Starting transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
if (null !== $savepoint) {
if (!$this->in_transaction) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null, 'savepoint cannot be released when changes are auto committed', __FUNCTION__);
}
$query = 'SAVE TRANSACTION ' . $savepoint;
return $this->_doQuery($query, true);
}
if ($this->in_transaction) {
return MDB2_OK;
//nothing to do
}
if (!$this->destructor_registered && $this->opened_persistent) {
$this->destructor_registered = true;
register_shutdown_function('MDB2_closeOpenTransactions');
}
if (MDB2::isError(sqlsrv_begin_transaction($this->connection))) {
return MDB2_ERROR;
}
$this->in_transaction = true;
return MDB2_OK;
}
示例14: _begin
/**
* DB transaction start
* this method is private
* @return boolean
*/
function _begin($transactionLevel = 0)
{
$connection = $this->_getConnection('master');
if (!$transactionLevel) {
if (sqlsrv_begin_transaction($connection) === false) {
return;
}
} else {
$this->_query("SAVE TRANS SP" . $transactionLevel, $connection);
}
return true;
}
示例15: get_booking_info
//get_area_settings($area);
//$notify_by_email = $mail_settings['on_delete'] && $need_to_send_mail;
/*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) {