本文整理匯總了PHP中rollback函數的典型用法代碼示例。如果您正苦於以下問題:PHP rollback函數的具體用法?PHP rollback怎麽用?PHP rollback使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了rollback函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postLunbo
public function postLunbo()
{
$options = $this->request()->only(['lb_image1', 'lb_url1', 'lb_title1', 'lb_image2', 'lb_url2', 'lb_title2', 'lb_image3', 'lb_url3', 'lb_title3']);
try {
transaction();
foreach ($options as $key => $option) {
Option::where('key', $key)->update(['value' => $option]);
}
commit();
return $this->success('保存成功');
} catch (\Exception $exception) {
rollback();
}
return $this->error('修改失敗,請稍後再試');
}
示例2: commit
/** Commits a transaction. */
public function commit()
{
if ($this->rollBackOnly == true) {
rollback();
return;
}
--$this->count;
if ($this->count == 0) {
try {
$this->doCommit();
} finally {
sem_release($this->semId);
}
}
}
示例3: incluirFuncionario
public function incluirFuncionario($id, $credencial)
{
// $objDatos = new clsDatos();
$this->objDatos = new clsDatos();
$this->objDatos->conectar();
try {
$sql = "INSERT INTO Funcionario(credencial_fun,cod_per,status_fun) VALUES ('{$credencial}','{$id}','activo')";
$this->objDatos->ejecutar($sql);
} catch (Exception $e) {
rollback();
// transaction rolls back
echo "<script>alert('Error al Insertar')</script>";
exit;
}
$this->objDatos->desconectar();
return;
}
示例4: UpdatePlanetBatimentQueueList
function UpdatePlanetBatimentQueueList($planetid)
{
$RetValue = false;
$now = time();
begin_transaction();
$CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $planetid . "' FOR UPDATE", 'planets', true);
if (!$CurrentPlanet || $CurrentPlanet['b_building'] == 0 || $CurrentPlanet['b_building'] > $now) {
rollback();
return false;
}
$CurrentUser = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $CurrentPlanet['id_owner'] . "' LOCK IN SHARE MODE", 'users', true);
if (!$CurrentUser) {
return false;
}
PlanetResourceUpdate($CurrentUser, $CurrentPlanet, $CurrentPlanet['b_building'], false);
CheckPlanetBuildingQueue($CurrentPlanet, $CurrentUser);
commit();
}
示例5: check
public function check()
{
$this->begin('index.php?app=seller&ctl=admin_brand&act=index');
if (!$_POST) {
$this->end(false, '非法請求');
}
extract($_POST);
$mdl_brand = $this->app->model('brand');
$db = vmc::database();
$db->beginTransaction();
if ($status == 1) {
$mdl_b2c_brand = app::get('b2c')->model('brand');
if (!($brand_id = $mdl_b2c_brand->insert($brand))) {
$db->rollback();
}
}
$data = compact('id', 'brand_id', 'status', 'why');
if (!$mdl_brand->save($data)) {
$db - rollback();
$this->end(false, '審核失敗');
}
$db->commit();
$this->end(true, '審核成功');
}
示例6: AwlQuery
}
$sql .= ' WHERE dav_name = :src_name';
$params[':src_name'] = $src_name;
$qry = new AwlQuery($sql, $params);
if (!$qry->Exec('move')) {
rollback(500);
}
$qry = new AwlQuery('SELECT write_sync_change( :src_collection, 404, :src_name );', array(':src_name' => $src_name, ':src_collection' => $src_collection));
if (!$qry->Exec('move')) {
rollback(500);
}
if (function_exists('log_caldav_action')) {
log_caldav_action('DELETE', $src->GetProperty('uid'), $src_user_no, $src_collection, $src_name);
}
$qry = new AwlQuery('SELECT write_sync_change( :dst_collection, :sync_type, :dst_name );', array(':dst_name' => $dst_name, ':dst_collection' => $dst_collection, ':sync_type' => $dest->Exists() ? 200 : 201));
if (!$qry->Exec('move')) {
rollback(500);
}
if (function_exists('log_caldav_action')) {
log_caldav_action($dest->Exists() ? 'UPDATE' : 'INSERT', $src->GetProperty('uid'), $dst_user_no, $dst_collection, $dst_name);
}
}
$qry = new AwlQuery('COMMIT');
if (!$qry->Exec('move')) {
rollback(500);
}
// We need to delete from the cache *after* we commit the transaction :-)
foreach ($cachekeys as $cache_ns) {
$cache->delete($cache_ns, null);
}
$request->DoResponse(200);
示例7: insert_sql_data
//.........這裏部分代碼省略.........
{
$p_campaigns[0][ 'Customer Record' ] = cust_record( $cust_name, OPERATOR_NAME );
$success = !is_null( $p_campaigns[0][ 'Customer Record' ]);
} // if customer_insert
if ($success)
{
$new_customer = TRUE;
message_log_append( $msg_log, "Customer created: " . "Seq = $cindex, Name = '$cust_name'", MSG_LOG_WARNING );
}
else
{
message_log_append( $msg_log, "Error while creating " . "Customer '$cust_name' " . mysql_error( $db_conn ), MSG_LOG_ERROR );
}
} // if null customer record
if ($success)
{
// build the list of header fields, in order with 'quote required' flag
// [n][0] is field name, [n][1] is boolean T=quote required, F=not
$hdr_flds = build_header_field_array();
// A SQL INSERT statement lead-in
$hdr_sql = "INSERT INTO temp_header ( ";
$hdr_sql .= fld_list( $hdr_flds ) . ") VALUES\n";
// build the list of detail fields, in order with 'quote required' flag
// [n][0] is field name, [n][1] is boolean T=quote required, F=not
$det_flds = build_detail_field_array();
// A SQL INSERT statement lead-in
$det_sql = "INSERT INTO temp_detail ( ";
$det_sql .= fld_list( $det_flds ) . ") VALUES ";
// Here we go. We'll loop through each contract header record,
// and its accompanying detail records.
$n_inserted = 0;
while ($success && (list( $key ) = each( $p_headers )))
{
if (count( $p_details[ $key ] ) > 0)
{
// If we created a new agency or customer above, update
// the respective header fields.
if ($new_customer)
{
$p_headers[ $key ][ 'CIndex' ] = $cindex;
$p_headers[ $key ][ 'Discount' ] = $p_campaigns[0][ 'Customer Record' ][ 'Discount' ];
}
if ($new_agency)
{
$p_headers[ $key ][ 'AIndex' ] = $aindex;
$p_headers[ $key ][ 'AgencyComm' ] = $p_campaigns[0][ 'Agency Record' ][ 'Rate' ];
}
$row = data_values( $hdr_flds, $p_headers[ $key ] );
$sql_header = $hdr_sql; // INSERT INTO ... VALUES
$sql_header .= "(" . $row . ");";
$rows = "";
foreach ($p_details[ $key ] as $line)
{
$rows .= ",\n( " . data_values( $det_flds, $line ) . " )";
}
$rows = substr( $rows, 1 ); // remove comma-newline
$sql_detail = $det_sql; // INSERT INTO ... VALUES
$sql_detail .= $rows;
if ($success = do_insert( $db_conn, $sql_header, $sql_detail ))
{
$n_inserted++;
}
} // if detail count > 0
} // while success and each key
} // if success
if ($success)
{
$success = commit( $db_conn );
if ($success)
{
message_log_append( $msg_log, "$n_inserted contract" . ($n_inserted == 1 ? '' : 's') . " imported" );
}
else
{
message_log_append( $msg_log, "Error in COMMIT TRANSACTION: " . mysql_error( $db_conn ), MSG_LOG_ERROR );
if (!rollback( $db_conn ))
{
message_log_append( $msg_log, "Error in ROLLBACK TRANSACTION: " . mysql_error( $db_conn ), MSG_LOG_ERROR );
}
}
}
else
{
if (!rollback( $db_conn ))
{
message_log_append( $msg_log, "Error in ROLLBACK TRANSACTION: " . mysql_error( $db_conn ), MSG_LOG_ERROR );
}
} // if success
return( $success );
} // insert_sql_data
示例8: rollback
public function rollback()
{
return rollback($this->conn);
}
示例9: postAdd
public function postAdd(Register $register)
{
//驗證表單
$this->validate($this->request(), ['mobile' => 'required|digits:11', 'birthday' => 'required|date', 'sex' => 'required|in:' . array_keys_impload(UserEnum::$sexForm), 'password' => 'required|min:5|max:20', 'password_confirm' => 'required|required_with:password|same:password', 'marital_status' => 'in:' . array_keys_impload(UserEnum::$maritalForm), 'height' => 'digits:3|between:130,210', 'education' => 'in:' . array_keys_impload(UserEnum::$educationForm), 'salary' => 'in:' . array_keys_impload(UserEnum::$salaryForm), 'user_name' => 'required|min:2|max:15|unique:users', 'email' => 'required|email|unique:users']);
$form = $this->request()->only(['user_name', 'email', 'mobile', 'birthday', 'password', 'marital_status', 'height', 'education', 'salary', 'province', 'city', 'area']);
try {
transaction();
$user = User::create($form);
$register->delete();
commit();
return $this->success('添加成功', $user);
} catch (\Exception $exp) {
rollback();
return $this->error('抱歉,添加失敗');
}
}
示例10: dump_database
}
$result = dump_database($next_ver);
if ($result === false) {
echo implode(',', $err->last_message());
} else {
echo 'OK';
}
break;
case 'rollback':
include_once ROOT_PATH . 'includes/cls_json.php';
$json = new JSON();
$next_ver = isset($_REQUEST['next_ver']) ? $_REQUEST['next_ver'] : '';
if ($next_ver === '') {
die('EMPTY');
}
$result = rollback($next_ver);
if ($result === false) {
echo implode(',', $err->last_message());
} else {
echo 'OK';
}
break;
/* 升級文件 */
/* 升級文件 */
case 'update_files':
include_once ROOT_PATH . 'includes/cls_json.php';
$json = new JSON();
$next_ver = isset($_REQUEST['next_ver']) ? $_REQUEST['next_ver'] : '';
if ($next_ver === '') {
die('EMPTY');
}
示例11: rollback
// 寫超級管理基本授權
$sql = "SELECT * FROM auth_node WHERE node = 'account.authorize.put'";
$sth = $pdo->query($sql);
$sth->execute();
$auth_node = $sth->fetch(PDO::FETCH_ASSOC);
if (!$auth_node) {
rollback($pdo);
return send_exit_single('user role authorize failed (fetch auth node).');
}
$sql = "INSERT INTO authorize(flag, company_id, auth_role_id, auth_node_id)VALUE(1, :company_id, :auth_role_id, :auth_node_id)";
$prepared = $pdo->prepare($sql);
$prepared->bindParam(':company_id', $company_id);
$prepared->bindParam(':auth_role_id', $auth_role_id);
$prepared->bindParam(':auth_node_id', $auth_node['id']);
if (!$prepared->execute()) {
rollback($pdo);
return send_exit_single('user role authorize failed (authorize).');
}
// 創建session表
$pdo->exec("CREATE TABLE IF NOT EXISTS `session` (\n `session_id` varchar(255) NOT NULL,\n `session_expire` int(11) NOT NULL,\n `session_data` blob,\n UNIQUE KEY `session_id` (`session_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
// 寫應用表
$sql = "INSERT INTO app(alias, requirements)VALUES(:alias, :requirements)";
$prepared = $pdo->prepare($sql);
foreach ($apps as $alias => $app_config) {
$requirements = $app_config['requirements'];
$prepared->bindParam(':alias', $alias);
$prepared->bindParam(':requirements', $requirements);
$prepared->execute();
}
display_loading('initialize company and super-user', 5);
file_put_contents(ENTRY_PATH . '/Data/install.lock', time());
示例12: audit
$response .= $res . "|||";
if ($datato == 'citas') {
$amot = 'Pac: ' . $_POST["PACIENTE_CIT"] . ' - Esp: ' . $_POST["BAREMO_CIT"] . ' - Med: ' . $_POST["PROVEEDOR_CIT"];
}
audit($datato, 'I', $res, $amot);
}
} elseif (isset($_POST[$_GET["saveidcampo" . $ix]])) {
$response .= $_POST[$_GET["saveidcampo" . $ix]] . "|||";
} elseif (isset($adds[$_GET["saveidcampo" . $ix]])) {
$response .= $adds[$_GET["saveidcampo" . $ix]] . "|||";
}
}
}
}
} else {
$data = "<span style='color:green'><br>Ya existe este codigo<b/><br/>Ya sido cargado en el formulario</span>|||" . $_POST[$saveidcampo];
rollback();
}
$txt = "agregados";
}
if ($data) {
echo $data;
} else {
if ($result) {
echo "<b>Datos {$txt} con exito...</b>|||" . $response;
} else {
//putxt(mssql_get_last_message());
echo "<span style='color:#999'>No se completo la operación...</span>|||" . $response;
}
}
commit();
示例13: saveIndiceEstacional
function saveIndiceEstacional($oData)
{
begin();
$sql = "SELECT * FROM indices_estacionales WHERE id_producto = " . $oData["id_producto"];
$result = getRS($sql);
if (!getNrosRows($result)) {
$dur_periodo = $this->getDuracionPeriodo();
$cant_dias_anio = date("z", mktime(0, 0, 0, 12, 31, date("Y"))) + 1;
$periodo_x_anio = number_format($cant_dias_anio / $dur_periodo);
for ($i = 0; $i < $periodo_x_anio; $i++) {
if ($i + 1 == $oData["nro_estacion"]) {
$sql = "INSERT INTO indices_estacionales (id_producto, orden, valor) VALUES (" . $oData["id_producto"] . "," . ($i + 1) . ", " . $oData["indice_estacional"] . ")";
} else {
$sql = "INSERT INTO indices_estacionales (id_producto, orden) VALUES (" . $oData["id_producto"] . "," . ($i + 1) . ")";
}
$rs = getRS($sql);
if (!$rs) {
die('Error: ' . mysql_error());
rollback();
} else {
commit();
}
}
} else {
$sql = "SELECT * FROM indices_estacionales WHERE id_producto = " . $oData["id_producto"] . " and orden = " . $oData["nro_estacion"];
$result = getRS($sql);
if (!getNrosRows($result)) {
$sql = "INSERT INTO indices_estacionales (id_producto, orden, valor) VALUES (" . $oData["id_producto"] . "," . $oData["nro_estacion"] . ", " . $oData["indice_estacional"] . ")";
$rs = getRS($sql);
if (!$rs) {
die('Error: ' . mysql_error());
rollback();
}
} else {
$sql = "UPDATE indices_estacionales SET valor = " . $oData["indice_estacional"] . " WHERE id_producto = " . $oData["id_producto"] . " AND orden = " . $oData["nro_estacion"];
$rs = getRS($sql);
if (!$rs) {
die('Error: ' . mysql_error());
rollback();
}
}
}
}
示例14: postRegister
public function postRegister()
{
$this->validate($this->request(), array('realname' => 'required', 'mobile' => 'required|size:11|unique:users,mobile', 'sex' => 'required:in:' . array_keys_impload(\App\Enum\User::$sexLang), 'birthday' => 'required|date', 'marriage' => 'required|in:' . array_keys_impload(\App\Enum\User::$marriageLang), 'like' => 'exists:users,user_id'), array('realname.required' => '請填寫真實姓名', 'mobile.required' => '請填寫手機號', 'mobile.size' => '手機號格式不正確', 'mobile.unique' => '手機號已被注冊', 'sex.required' => '請選擇您的性別', 'sex.in' => '您填寫的性別有誤', 'birthday.required' => '請填寫您的生日', 'birthday.date' => '您填寫的生日格式不正確', 'marriage.required' => '您填寫您的婚姻狀態', 'marriage.in' => '婚姻狀態不正確', 'like.exist' => '您報名的對象不存在'));
$form = $this->request()->only('realname', 'mobile', 'sex', 'birthday', 'marriage');
try {
transaction();
//創建用戶
$user = User::create($form);
if ($this->request()->has('like')) {
//創建喜歡的人
$user->like()->create(array('like_user_id' => $this->request()->get('like')));
}
//創建用戶信息
$user->info()->create(array());
//創建擇偶條件
$user->object()->create(array('sex' => $user->sex == \App\Enum\User::SEX_FEMALE ? \App\Enum\User::SEX_MALE : \App\Enum\User::SEX_FEMALE));
commit();
return $this->rest()->success($user, '報名成功,管理員審核通過後即可登錄');
} catch (\Exception $ex) {
rollback();
dd($ex->getMessage());
return $this->rest()->error('抱歉,報名失敗,請稍後再試');
}
}
示例15: update
function update($p_array)
{
$this->load();
// if name is empty return immediately
if (trim(strlen($p_array['md_name'])) == 0) {
return;
}
try {
// Start transaction
$this->cn->start();
$sql = "update document_modele set md_name=\$1,md_type=\$2,md_affect=\$3 where md_id=\$4";
$this->cn->exec_sql($sql, array($p_array['md_name'], $p_array['md_type'], $p_array['md_affect'], $this->md_id));
if ($p_array['seq'] != 0) {
$this->cn->alter_seq('seq_doc_type_' . $p_array['md_type'], $p_array['seq']);
}
// Save the file
$new_name = tempnam($_ENV['TMP'], 'document_');
if (strlen($_FILES['doc']['tmp_name']) != 0) {
if (move_uploaded_file($_FILES['doc']['tmp_name'], $new_name)) {
// echo "Image saved";
$oid = $this->cn->lo_import($new_name);
if ($oid == false) {
echo_error('class_document_modele.php', __LINE__, "cannot upload document");
$this->cn->rollback();
return;
}
// Remove old document
$ret = $this->cn->exec_sql("select md_lob from document_modele where md_id=" . $this->md_id);
if (Database::num_row($ret) != 0) {
$r = Database::fetch_array($ret, 0);
$old_oid = $r['md_lob'];
if (strlen($old_oid) != 0) {
$this->cn->lo_unlink($old_oid);
}
}
// Load new document
$this->cn->exec_sql("update document_modele set md_lob=" . $oid . ", md_mimetype='" . $_FILES['doc']['type'] . "' ,md_filename='" . $_FILES['doc']['name'] . "' where md_id=" . $this->md_id);
$this->cn->commit();
} else {
echo "<H1>Error</H1>";
$this->cn->rollback();
throw new Exception("Erreur" . __FILE__ . __LINE__);
}
}
} catch (Exception $e) {
rollback($this->cn);
return;
}
$this->cn->commit();
}