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


PHP commit函数代码示例

本文整理汇总了PHP中commit函数的典型用法代码示例。如果您正苦于以下问题:PHP commit函数的具体用法?PHP commit怎么用?PHP commit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了commit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: yay_parse

function yay_parse(string $source, Directives $directives = null, BlueContext $blueContext = null) : string
{
    if ($gc = gc_enabled()) {
        gc_disable();
    }
    // important optimization!
    static $globalDirectives = null;
    if (null === $globalDirectives) {
        $globalDirectives = new ArrayObject();
    }
    $directives = $directives ?: new Directives();
    $blueContext = $blueContext ?: new BlueContext();
    $cg = (object) ['ts' => TokenStream::fromSource($source), 'directives' => $directives, 'cycle' => new Cycle($source), 'globalDirectives' => $globalDirectives, 'blueContext' => $blueContext];
    foreach ($cg->globalDirectives as $d) {
        $cg->directives->add($d);
    }
    traverse(midrule(function (TokenStream $ts) use($directives, $blueContext) {
        $token = $ts->current();
        tail_call:
        if (null === $token) {
            return;
        }
        // skip when something looks like a new macro to be parsed
        if ('macro' === (string) $token) {
            return;
        }
        // here we do the 'magic' to match and expand userland macros
        $directives->apply($ts, $token, $blueContext);
        $token = $ts->next();
        goto tail_call;
    }), consume(chain(token(T_STRING, 'macro')->as('declaration'), optional(repeat(rtoken('/^·\\w+$/')))->as('tags'), lookahead(token('{')), commit(chain(braces()->as('pattern'), operator('>>'), braces()->as('expansion')))->as('body'), optional(token(';'))), CONSUME_DO_TRIM)->onCommit(function (Ast $macroAst) use($cg) {
        $scope = Map::fromEmpty();
        $tags = Map::fromValues(array_map('strval', $macroAst->{'tags'}));
        $pattern = new Pattern($macroAst->{'declaration'}->line(), $macroAst->{'body pattern'}, $tags, $scope);
        $expansion = new Expansion($macroAst->{'body expansion'}, $tags, $scope);
        $macro = new Macro($tags, $pattern, $expansion, $cg->cycle);
        $cg->directives->add($macro);
        // allocate the userland macro
        // allocate the userland macro globally if it's declared as global
        if ($macro->tags()->contains('·global')) {
            $cg->globalDirectives[] = $macro;
        }
    }))->parse($cg->ts);
    $expansion = (string) $cg->ts;
    if ($gc) {
        gc_enable();
    }
    return $expansion;
}
开发者ID:lastguest,项目名称:yay,代码行数:49,代码来源:yay_parse.php

示例2: layer

 private function layer(string $start, string $end, Parser $parser, $cg) : Parser
 {
     return chain(token($start), rtoken('/^···(\\w+)$/')->as('label'), commit(token($end)))->onCommit(function (Ast $result) use($parser, $cg) {
         $id = $this->lookupCapture($result->label);
         $cg->parsers[] = (clone $parser)->as($id);
     });
 }
开发者ID:lastguest,项目名称:yay,代码行数:7,代码来源:Pattern.php

示例3: transaction_started

function transaction_started()
{
    global $db;
    try {
        if ($db->beginTransaction()) {
            return true;
        }
        $db - commit();
        return false;
    } catch (PDOException $e) {
        return true;
    }
}
开发者ID:ArbalestX,项目名称:megatendb,代码行数:13,代码来源:backend.php

示例4: 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

示例5: 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

示例6: transferir

 function transferir($idOrigem, $cadastroOrigem, $valor, $idDestino, $cadastroDestino)
 {
     if ($this->isPessoaJuridica($cadastroDestino)) {
         try {
             beginTransaction();
             $ps = $this->executar('SELECT * FROM conta WHERE id_conta = ?', array($idOrigem));
             $p = $ps->fetchObject();
             if ($p->saldo < $valor) {
                 rollBack();
                 throw new TransferenciaException('Saldo da conta de origem insuficiente');
             }
             $ps = $this->executar('UPDATE conta SET saldo = saldo - ? WHERE id_conta = ?', array($valor, $idOrigem));
             $valorDoisPorCento = $valor * 0.02;
             $valorNovo = $valor - $valor * 0.02;
             $ps = $this->executar('UPDATE conta SET saldo = saldo + ? WHERE id_conta = ?', array($valorDoisPorCento, 0));
             $ps = $this->executar('UPDATE conta SET saldo = saldo + ? WHERE id_conta = ?', array($valorNovo, $idDestino));
             commit();
         } catch (Exception $e) {
             rollBack();
             throw new TransferenciaException('Erro ao realizar transferencia');
         }
     } else {
         try {
             beginTransaction();
             $ps = $this->executar('SELECT * FROM conta WHERE id_conta = ?', array($idOrigem));
             $p = $ps->fetchObject();
             if ($p->saldo < $valor) {
                 rollBack();
                 throw new TransferenciaException('Saldo da conta de origem insuficiente');
             }
             $ps = $this->executar('UPDATE conta SET saldo = saldo - ? WHERE id_conta = ?', array($valor, $idOrigem));
             $ps = $this->executar('UPDATE conta SET saldo = saldo + ? WHERE id_conta = ?', array($valor, $idDestino));
             commit();
         } catch (Exception $e) {
             rollBack();
             throw new TransferenciaException('Erro ao realizar transferencia');
         }
     }
 }
开发者ID:alebagran,项目名称:php-cefet,代码行数:39,代码来源:transferencia.php

示例7: insert_sql_data

function insert_sql_data( $db_conn, $p_campaigns, $p_headers, $p_details )
// insert the header and detail data into the file
// with appropriate safeguards to ensure full 
// completion or rollback of the transaction.
{
GLOBAL $msg_log;

	$success = TRUE;
// Wrap all this in a transaction
// First, turn off autocommit
	$qry = "set autocommit=0";
//pre_echo( $qry );
	$success = mysql_query( $qry, $db_conn );

// Second, take care of all ALTER TABLE queries.  Due to a (documented)
// glitch in MySQL, these commands force a transaction to commit, 
// which sucks.

	if ($success) 
	{ // Create the temp_header table
		$qry = "CREATE TEMPORARY TABLE temp_header LIKE contract_header";
//pre_echo( $qry );
		$success = mysql_query( $qry, $db_conn );
		if (!$success) 
		{
			message_log_append( $msg_log, mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

	if ($success) 
	{ // Create the temp_detail table
		$qry = "CREATE TEMPORARY TABLE temp_detail LIKE contract_detail";
//pre_echo( $qry );
		$success = mysql_query( $qry, $db_conn );
		if (!$success)
		{
			message_log_append( $msg_log, mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

	if ($success) 
	{ // Delete the Seq field from table temp_header
		$qry = "ALTER TABLE temp_header DROP COLUMN Seq";
//pre_echo( $qry );
		$success = mysql_query( $qry, $db_conn );
		if (!$success)
		{
			message_log_append( $msg_log, mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

    if ($success) 
	{ // Delete the Line column from table temp_detail
		$qry = "ALTER TABLE temp_detail DROP COLUMN Line";
//pre_echo( $qry );
		$success = mysql_query( $qry, $db_conn );
		if (!$success)
		{
			message_log_append( $msg_log, mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

// loop through the campaigns, headers, and details to insert the
// data into the SQL database.  Keep solid track of all error
// results so that we can ROLLBACK on any error.
	if ($success) 
	{
//echo "<pre>";
//var_dump( $p_campaigns );  echo "</pre><br>";
		$success = begin( $db_conn );
		if (!$success)
		{
			message_log_append( $msg_log, "Error in START TRANSACTION: " . mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

// do the work here, and keep track of $success
// If we need to create a new agency record, do that here.
	$new_agency = FALSE;
	if ($success && is_null( $p_campaigns[0][ 'Agency Record' ])) 
	{
		$agent_name = $p_campaigns[0][ 'Agency Name' ];
		$rate = DEFAULT_AGENCY_RATE / 10;
		if ($success = agency_insert( $db_conn, $agent_name, $rate, $aindex )) 
		{
			$p_campaigns[0][ 'Agency Record' ] = agency_record( $agent_name, OPERATOR_NAME );
			$success = !is_null( $p_campaigns[0][ 'Agency Record' ]);
		} // if agency_insert
		if ($success) 
		{
			$new_agency = TRUE;
			message_log_append( $msg_log, "Agency created: " .
			"Seq = $aindex, Name = '$agent_name'", MSG_LOG_WARNING );
		} 
		else 
		{
			message_log_append( $msg_log, "Error while creating " . "Agency '$agent_name': " . mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	} // if null agency record

//.........这里部分代码省略.........
开发者ID:agundran,项目名称:addige,代码行数:101,代码来源:insert_sql.php

示例8: save

 function save($oData)
 {
     if (!$oData["id_orden_compra"]) {
         begin();
         $detalle = array();
         $cabecera = array();
         $cabecera = explode("@@", $oData["cabecera"]);
         $detalle = explode("||", $oData["detalle"]);
         $sql = "INSERT INTO  ordenes_compra (id_proveedor, fecha_orden_compra, nro_orden_compra, generada)\r\n\t\t\t\t\tVALUES (" . $cabecera[0] . ", '" . dateToMySQL($cabecera[1]) . "', " . $cabecera[2] . ", 1)";
         if (!mysql_query($sql)) {
             die('Error: ' . mysql_error());
             rollback();
             return false;
         } else {
             $id = mysql_insert_id();
             foreach ($detalle as $detail) {
                 $values = explode("@@", $detail);
                 $sql = "INSERT INTO detalle_ordenes_compra (id_orden_compra, id_producto, cantidad_detalle_orden_compra) VALUES  (" . $id . ", " . $values[0] . ", " . $values[1] . ")";
                 if (!mysql_query($sql)) {
                     die('Error: ' . mysql_error());
                     rollback();
                     break;
                 }
             }
             if ($cabecera[2]) {
                 $nroVta = $cabecera[2] + 1;
             }
             $sql = "UPDATE parametros SET valor_parametro = " . $nroVta . " WHERE nombre_parametro='nro_orden_compra'";
             if (!mysql_query($sql)) {
                 die('Error: ' . mysql_error());
                 rollback();
                 break;
             } else {
                 commit();
                 return true;
             }
             return false;
         }
     } else {
         $sql = "delete from detalle_ordenes_compra where id_orden_compra=" . $oData["id_orden_compra"];
         getRS($sql);
         $sql = "delete from ordenes_compra where id_orden_compra=" . $oData["id_orden_compra"];
         getRS($sql);
         begin();
         $detalle = array();
         $cabecera = array();
         $cabecera = explode("@@", $oData["cabecera"]);
         $detalle = explode("||", $oData["detalle"]);
         $sql = "INSERT INTO  ordenes_compra (id_proveedor, fecha_orden_compra, nro_orden_compra, generada)\r\n\t\t\t\t\tVALUES (" . $cabecera[0] . ", '" . dateToMySQL($cabecera[1]) . "', " . $cabecera[2] . ", 1)";
         if (!mysql_query($sql)) {
             die('Error: ' . mysql_error());
             rollback();
             return false;
         } else {
             $id = mysql_insert_id();
             foreach ($detalle as $detail) {
                 $values = explode("@@", $detail);
                 $sql = "INSERT INTO detalle_ordenes_compra (id_orden_compra, id_producto, cantidad_detalle_orden_compra) VALUES  (" . $id . ", " . $values[0] . ", " . $values[1] . ")";
                 if (!mysql_query($sql)) {
                     die('Error: ' . mysql_error());
                     rollback();
                     break;
                 }
             }
             if ($cabecera[2]) {
                 $nroVta = $cabecera[2] + 1;
             }
             $sql = "UPDATE parametros SET valor_parametro = " . $nroVta . " WHERE nombre_parametro='nro_orden_compra'";
             if (!mysql_query($sql)) {
                 die('Error: ' . mysql_error());
                 rollback();
                 break;
             } else {
                 commit();
                 return true;
             }
             return false;
         }
     }
 }
开发者ID:sugarnet,项目名称:feanor-sg1,代码行数:80,代码来源:ExpertoOrdenes.php

示例9: commit

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

示例10: mysql_query

// Get the comments about the user
$commentsResult = mysql_query("SELECT * FROM comments WHERE comments.to_user_id={$userId}", $link) or die("ERROR: Query failed for the list of comments.");
if (mysql_num_rows($commentsResult) == 0) {
    print "<h2>There is no comment for this user.</h2><br>\n";
} else {
    print "<DL>\n";
    while ($commentsRow = mysql_fetch_array($commentsResult)) {
        $authorId = $commentsRow["from_user_id"];
        $authorResult = mysql_query("SELECT nickname FROM users WHERE users.id={$authorId}", $link) or die("ERROR: Query failed for the comment author.");
        if (mysql_num_rows($authorResult) == 0) {
            die("ERROR: This author does not exist.<br>\n");
        } else {
            $authorRow = mysql_fetch_array($authorResult);
            $authorName = $authorRow["nickname"];
        }
        $date = $commentsRow["date"];
        $comment = $commentsRow["comment"];
        print "<DT><b><BIG><a href=\"/PHP/ViewUserInfo.php?userId=" . $authorId . "\">{$authorName}</a></BIG></b>" . " wrote the " . $date . "<DD><i>" . $comment . "</i><p>\n";
        mysql_free_result($authorResult);
    }
    print "</DL>\n";
}
commit($link);
mysql_free_result($userResult);
mysql_free_result($commentsResult);
mysql_close($link);
printHTMLfooter($scriptName, $startTime);
?>
  </body>
</html>
开发者ID:michaelprem,项目名称:phc,代码行数:30,代码来源:ViewUserInfo.php

示例11: strip_horde

    $c->writeln(_("Found directories:"));
    $c->writeln(implode("\n", $dirs));
}
$apps = strip_horde($dirs);
$apps[0] = 'horde';
$c->writeln(wordwrap(sprintf(_("Found applications: %s"), implode(', ', $apps))));
$c->writeln();
switch ($cmd) {
    case 'cleanup':
    case 'commit':
    case 'compendium':
    case 'merge':
        $cmd();
        break;
    case 'commit-help':
        commit(true);
        break;
    case 'extract':
        xtract();
        break;
    case 'init':
        init();
        $c->writeln();
        merge();
        break;
    case 'make':
        cleanup(true);
        $c->writeln();
        make();
        break;
    case 'make-help':
开发者ID:Artea,项目名称:freebeer,代码行数:31,代码来源:translation.php

示例12: HandleTechnologieBuild

function HandleTechnologieBuild(&$CurrentPlanet, &$CurrentUser)
{
    global $resource;
    if ($CurrentUser['b_tech_planet'] != 0) {
        // Y a une technologie en cours sur une de mes colonies
        if ($CurrentUser['b_tech_planet'] != $CurrentPlanet['id']) {
            // Et ce n'est pas sur celle ci !!
            $WorkingPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $CurrentUser['b_tech_planet'] . "';", 'planets', true);
        }
        if (isset($WorkingPlanet) && $WorkingPlanet) {
            $ThePlanet = $WorkingPlanet;
        } else {
            $ThePlanet = $CurrentPlanet;
        }
        $now = time();
        if ($ThePlanet['b_tech'] <= $now && $ThePlanet['b_tech_id'] != 0) {
            begin_transaction();
            $Me = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $CurrentUser['id'] . "' FOR UPDATE", 'users', true);
            if ($Me['b_tech_planet'] == $CurrentUser['b_tech_planet']) {
                $Result['WorkOn'] = "";
                $Result['OnWork'] = false;
                return $Result;
            }
            $ThePlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $ThePlanet['id'] . "' FOR UPDATE", 'planets', true);
            if ($ThePlanet['b_tech'] > $now || $ThePlanet['b_tech_id'] == 0) {
                $Result['WorkOn'] = $ThePlanet;
                $Result['OnWork'] = true;
                return $Result;
            }
            // La recherche en cours est terminée ...
            $CurrentUser[$resource[$ThePlanet['b_tech_id']]]++;
            // Mise a jour de la planete sur laquelle la technologie a été recherchée
            $QryUpdatePlanet = "UPDATE {{table}} SET ";
            $QryUpdatePlanet .= "`b_tech` = '0', ";
            $QryUpdatePlanet .= "`b_tech_id` = '0' ";
            $QryUpdatePlanet .= "WHERE ";
            $QryUpdatePlanet .= "`id` = '" . $ThePlanet['id'] . "';";
            doquery($QryUpdatePlanet, 'planets');
            // Mes a jour de la techno sur l'enregistrement Utilisateur
            // Et tant qu'a faire des stats points
            $QryUpdateUser = "UPDATE {{table}} SET ";
            $QryUpdateUser .= "`" . $resource[$ThePlanet['b_tech_id']] . "` = '" . $CurrentUser[$resource[$ThePlanet['b_tech_id']]] . "', ";
            $QryUpdateUser .= "`b_tech_planet` = '0' ";
            $QryUpdateUser .= "WHERE ";
            $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';";
            doquery($QryUpdateUser, 'users');
            $ThePlanet["b_tech_id"] = 0;
            if (isset($WorkingPlanet)) {
                $WorkingPlanet = $ThePlanet;
            } else {
                $CurrentPlanet = $ThePlanet;
            }
            $Result['WorkOn'] = "";
            $Result['OnWork'] = false;
            commit();
        } elseif ($ThePlanet["b_tech_id"] == 0) {
            assert(false);
            // Il n'y a rien a l'ouest ...
            // Pas de Technologie en cours devait y avoir un bug lors de la derniere connexion
            // On met l'enregistrement informant d'une techno en cours de recherche a jours
            doquery("UPDATE {{table}} SET `b_tech_planet` = '0'  WHERE `id` = '" . $CurrentUser['id'] . "';", 'users');
            $Result['WorkOn'] = "";
            $Result['OnWork'] = false;
        } else {
            // Bin on bosse toujours ici ... Alors ne nous derangez pas !!!
            $Result['WorkOn'] = $ThePlanet;
            $Result['OnWork'] = true;
        }
    } else {
        $Result['WorkOn'] = "";
        $Result['OnWork'] = false;
    }
    return $Result;
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:74,代码来源:HandleTechnologieBuild.php

示例13: 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

示例14: mysql_error

		die ('No se encuentra la base de datos seleccionada : ' . mysql_error());
	}
	
	$lNumber = $_POST['leaseNum'];
	$sDate = $_POST['sDate'];
	$eDate = $_POST['eDate'];
	$duration = $_POST['duration'];
	$studentID = $_POST['student'];
	$placeNum = $_POST['room'];
	

	$contrato = "INSERT INTO Lease VALUES ('$lNumber', '$sDate', '$eDate', '$duration', '$studentID', '$placeNum')";
	begin(); // Empieza la transaccion
	$result = mysql_query($contrato);
	
	if(!$result) {
		
		rollback(); // Si hubo un error se le da rollback
		echo 'Hubo un error';
		exit;
	}
	
	else {
		commit(); //Si fue exitosa se lleva a cabo
		echo 'Operación realizada con éxito';
	}
	
	
	header("Location: confirmacion.php");
?>
开发者ID:rkrdo,项目名称:university,代码行数:30,代码来源:insertar_contrato.php

示例15: update_post_controller

/**
 * @post update
 */
function update_post_controller($id)
{
    __is_guest();
    if (!empty($_POST)) {
        if (checked_token($_POST['_token'])) {
            __session_start();
            $_SESSION['old'] = [];
            $_SESSION['errors'] = [];
            $rules = ['title' => FILTER_SANITIZE_STRING, 'content' => FILTER_SANITIZE_STRING, 'status' => ['filter' => FILTER_CALLBACK, 'options' => function ($s) {
                if (in_array($s, ['published', 'unpublished'])) {
                    return $s;
                } else {
                    return 'unpublished';
                }
            }], 'published_at' => ['filter' => FILTER_CALLBACK, 'options' => function ($checkbox) {
                if ($checkbox == 'yes') {
                    return new DateTime('now');
                }
            }]];
            $sanitize = filter_input_array(INPUT_POST, $rules);
            $id = (int) $id;
            // test if errors
            if (empty($_POST['title'])) {
                $_SESSION['errors']['title'] = 'title is required';
            }
            if (!empty($_SESSION['errors'])) {
                $_SESSION['old'] = $sanitize;
                redirect('post/create');
                // exit
            }
            if (!empty($_FILES['file']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
                try {
                    $dateFile = upload($_FILES['file']);
                    beginTransaction();
                    update_post_model($id, $sanitize);
                    create_media_model(['filename' => $dateFile['filename'], 'post_id' => $id, 'size' => $dateFile['size']]);
                    commit();
                    setFlashMessage("success stored");
                    redirect('dashboard');
                } catch (Exception $e) {
                    if ($e instanceof RuntimeException) {
                        $_SESSION['old'] = $sanitize;
                        $_SESSION['errors']['upload'] = $e->getMessage();
                        redirect('post/create');
                    }
                    rollback();
                    $_SESSION['old'] = $sanitize;
                    $_SESSION['errors']['file'] = $e->getMessage();
                    redirect('post/create');
                }
            } else {
                try {
                    beginTransaction();
                    update_post_model($id, $sanitize);
                    $media_id = (int) $_POST['m_id'];
                    if (!empty($_POST['m_id']) && !empty($_POST['delete_filename'])) {
                        $media = find_model($media_id, 'medias');
                        $m = $media->fetch();
                        destroy_model($media_id, 'medias');
                    }
                    commit();
                    if (!empty($m)) {
                        unlink(getEnv('UPLOAD_DIRECTORY') . '/' . htmlentities($m['m_filename']));
                    }
                    setFlashMessage(trans('success_updated_post', $sanitize['title']));
                    redirect('dashboard');
                } catch (Exception $e) {
                    rollback();
                    $_SESSION['old'] = $sanitize;
                    $_SESSION['errors']['file'] = $e->getMessage();
                    redirect('post/create');
                }
                throw new RuntimeException('418');
            }
        }
    }
}
开发者ID:Antoine07,项目名称:pmcv,代码行数:80,代码来源:controllers.php


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