本文整理汇总了PHP中PDO::begintransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP PDO::begintransaction方法的具体用法?PHP PDO::begintransaction怎么用?PHP PDO::begintransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDO
的用法示例。
在下文中一共展示了PDO::begintransaction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: begin
/**
Begin SQL transaction
@return NULL
**/
function begin()
{
parent::begintransaction();
$this->trans = TRUE;
}
示例2: begin
/**
* Begin SQL transaction
* @return bool
**/
function begin()
{
$out = parent::begintransaction();
$this->trans = TRUE;
return $out;
}
示例3: PDO
<html>
<body>
<?php
$userid = $_REQUEST['userid'];
$email = $_REQUEST['email'];
$nome = $_POST['nome'];
try {
$host = "db.ist.utl.pt";
$user = "ist177034";
$password = "sjxdqmu";
$dbname = $user;
$db = new PDO("mysql:host={$host};dbname={$dbname}", $user, $password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->begintransaction();
echo $userid;
echo $email;
echo $nome;
$date = date('Y-m-d H:i:s');
$sql = "INSERT INTO sequencia(userid,moment) VALUES ({$userid},'{$date}') ;";
$db->query($sql);
$sql2 = "select contador_sequencia from sequencia where contador_sequencia >= ALL(select contador_sequencia from sequencia);";
$contador_seq = $db->query($sql2);
foreach ($contador_seq as $row) {
$seqid = $row['contador_sequencia'];
$sql2 = "SELECT pagecounter + 1 as pg FROM(SELECT userid, pagecounter, nome, idseq, ativa FROM pagina WHERE pagecounter >= ALL(SELECT pagecounter FROM pagina)) a;";
$page_counter = $db->query($sql2);
foreach ($page_counter as $row) {
$pg_count = $row['pg'];
$sql3 = "INSERT INTO pagina(userid,pagecounter,nome,idseq,ativa) VALUES ({$userid}, {$pg_count} , '{$nome}', {$seqid},1);";
echo $sql3;
$db->query($sql3);