当前位置: 首页>>代码示例>>PHP>>正文


PHP rollback函数代码示例

本文整理汇总了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('修改失败,请稍后再试');
 }
开发者ID:netxinyi,项目名称:meigui,代码行数:15,代码来源:OptionController.php

示例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);
         }
     }
 }
开发者ID:andresrc,项目名称:tcus-php-as,代码行数:16,代码来源:SemRepository.php

示例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;
 }
开发者ID:anthonyovp,项目名称:Poliguaicaipuro,代码行数:17,代码来源:clsPersona.php

示例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();
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:18,代码来源:UpdatePlanetBatimentQueueList.php

示例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, '审核成功');
 }
开发者ID:yindonghai,项目名称:msk.com,代码行数:24,代码来源:brand.php

示例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);
开发者ID:derekyu1437,项目名称:davical,代码行数:31,代码来源:caldav-MOVE.php

示例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
开发者ID:agundran,项目名称:addige,代码行数:101,代码来源:insert_sql.php

示例8: rollback

 public function rollback()
 {
     return rollback($this->conn);
 }
开发者ID:jthemphill,项目名称:tournament,代码行数:4,代码来源:transaction.php

示例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('抱歉,添加失败');
     }
 }
开发者ID:netxinyi,项目名称:meigui,代码行数:16,代码来源:UserController.php

示例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');
     }
开发者ID:dw250100785,项目名称:ECShop-1,代码行数:31,代码来源:index.php

示例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());
开发者ID:chinapaul,项目名称:ones,代码行数:31,代码来源:install.php

示例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&oacute;n...</span>|||" . $response;
    }
}
commit();
开发者ID:lflores10,项目名称:EncuestasUSM,代码行数:31,代码来源:sdata.php

示例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();
             }
         }
     }
 }
开发者ID:sugarnet,项目名称:feanor-sg1,代码行数:43,代码来源:ExpertoPrediccion.php

示例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('抱歉,报名失败,请稍后再试');
     }
 }
开发者ID:netxinyi,项目名称:meigui,代码行数:24,代码来源:AuthController.php

示例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();
 }
开发者ID:Kloadut,项目名称:noalyss_ynh,代码行数:50,代码来源:class_document_modele.php


注:本文中的rollback函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。