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


PHP Connection::rollback方法代码示例

本文整理汇总了PHP中Connection::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::rollback方法的具体用法?PHP Connection::rollback怎么用?PHP Connection::rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


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

示例1: testTransactionRollback

 public function testTransactionRollback()
 {
     $this->createTable();
     $this->connection->beginTransaction();
     $this->connection->query("INSERT INTO cat (name, colour) VALUES (?, ?)", array('Nennek', 'black'));
     $this->connection->rollback();
     $statement = $this->connection->query("SELECT count(*) AS c FROM cat");
     $row = $this->connection->fetch($statement);
     $count = array_shift($row);
     $this->assertEquals(2, $count);
 }
开发者ID:renq,项目名称:Simqel,代码行数:11,代码来源:PDOTest.php

示例2: install_procedure

function install_procedure(Connection $connection, $procedure)
{
    $result = $connection->excecute($procedure);
    $sql = $connection->getLastQuery();
    if (!$result) {
        $connection->rollback();
        error($sql);
        return false;
    }
    ok($sql);
    return true;
}
开发者ID:exildev,项目名称:corvus,代码行数:12,代码来源:install.php

示例3: testRollback

 public function testRollback()
 {
     $exch = DriverTestManager::getExchange('RecordCount');
     $count_sql = $exch->getSql();
     $rs = $this->conn->executeQuery($count_sql, ResultSet::FETCHMODE_NUM);
     $rs->next();
     $total = $rs->getInt(1);
     // $this->assertEquals((int) $exch->getResult(), $total);
     $this->conn->setAutoCommit(false);
     // not sure exactly how to test this yet ...
     $exch = DriverTestManager::getExchange('ConnectionTest.setAutoCommit.DELTRAN1');
     $deleted1 = $this->conn->executeUpdate($exch->getSql());
     $exch = DriverTestManager::getExchange('ConnectionTest.setAutoCommit.DELTRAN2');
     $deleted2 = $this->conn->executeUpdate($exch->getSql());
     $this->conn->rollback();
     // compare the actual total w/ what we expect
     $rs = $this->conn->executeQuery($count_sql, ResultSet::FETCHMODE_NUM);
     $rs->next();
     $new_actual_total = $rs->getInt(1);
     $this->assertEquals($total, $new_actual_total, 0, "Failed to find correct (same) num of records in table after rollback().");
     $this->conn->setAutoCommit(true);
 }
开发者ID:BackupTheBerlios,项目名称:php5cms-svn,代码行数:22,代码来源:ConnectionTest.php

示例4: rollback

    /**
     * Roll back a transaction in databases that support transactions.
     * It also releases the connection. In databases that do not support
     * transactions, this method will log the attempt and release the
     * connection.
     *
     * @param Connection $con The Connection for the transaction.
     * @return void
     * @throws PropelException
     */
    public static function rollback($con)
    {
        if ($con === null) {
            throw new PropelException(
                    "Connection object was null. "
                    . "This could be due to a misconfiguration. "
                    . "Check the logs and Propel properties "
                    . "to better determine the cause.");
        }

        try {
            if ($con->getAutoCommit() === false) {
                $con->rollback();
                $con->setAutoCommit(true);
            }
        } catch (SQLException $e) {
            Propel::log(
                    "An attempt was made to rollback a transaction "
                    . "but the database did not allow the operation to be "
                    . "rolled back: " . $e->getMessage(), Propel::LOG_ERR);
            throw new PropelException($e);
        }
    }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:33,代码来源:Transaction.php

示例5: rollback

 /**
  * @see Connection::rollback()
  */
 public function rollback()
 {
     $this->log("Rolling back transaction.");
     return $this->childConnection->rollback();
 }
开发者ID:rodrigoprestesmachado,项目名称:whiteboard,代码行数:8,代码来源:DebugConnection.php

示例6: rollback

	/**
	 * Rollback transaction.
	 */
	public function rollback() {
		$this->connection->rollback();
	}
开发者ID:renq,项目名称:ML-Lib,代码行数:6,代码来源:SQL.php

示例7: execute

 /**
  * Execute this migration version up or down and and return the SQL.
  *
  * @param string $direction   The direction to execute the migration.
  * @param string $dryRun      Whether to not actually execute the migration SQL and just do a dry run.
  * @return array $sql
  * @throws Exception when migration fails
  */
 public function execute($direction, $dryRun = false)
 {
     $this->_sql = array();
     $this->_connection->beginTransaction();
     try {
         $start = microtime(true);
         $this->_state = self::STATE_PRE;
         $fromSchema = $this->_sm->createSchema();
         $this->_migration->{'pre' . ucfirst($direction)}($fromSchema);
         if ($direction === 'up') {
             $this->_outputWriter->write("\n" . sprintf('  <info>++</info> migrating <comment>%s</comment>', $this->_version) . "\n");
         } else {
             $this->_outputWriter->write("\n" . sprintf('  <info>--</info> reverting <comment>%s</comment>', $this->_version) . "\n");
         }
         $this->_state = self::STATE_EXEC;
         $toSchema = clone $fromSchema;
         $this->_migration->{$direction}($toSchema);
         $this->addSql($fromSchema->getMigrateToSql($toSchema, $this->_platform));
         if ($dryRun === false) {
             if ($this->_sql) {
                 $count = count($this->_sql);
                 foreach ($this->_sql as $query) {
                     $this->_outputWriter->write('     <comment>-></comment> ' . $query);
                     $this->_connection->executeQuery($query);
                 }
             } else {
                 $this->_outputWriter->write(sprintf('<error>Migration %s was executed but did not result in any SQL statements.</error>', $this->_version));
             }
             if ($direction === 'up') {
                 $this->markMigrated();
             } else {
                 $this->markNotMigrated();
             }
         } else {
             foreach ($this->_sql as $query) {
                 $this->_outputWriter->write('     <comment>-></comment> ' . $query);
             }
         }
         $this->_state = self::STATE_POST;
         $this->_migration->{'post' . ucfirst($direction)}($toSchema);
         $end = microtime(true);
         $this->_time = round($end - $start, 2);
         if ($direction === 'up') {
             $this->_outputWriter->write(sprintf("\n  <info>++</info> migrated (%ss)", $this->_time));
         } else {
             $this->_outputWriter->write(sprintf("\n  <info>--</info> reverted (%ss)", $this->_time));
         }
         $this->_connection->commit();
         return $this->_sql;
     } catch (SkipMigrationException $e) {
         $this->_connection->rollback();
         // now mark it as migrated
         if ($direction === 'up') {
             $this->markMigrated();
         } else {
             $this->markNotMigrated();
         }
         $this->_outputWriter->write(sprintf("\n  <info>SS</info> skipped (Reason: %s)", $e->getMessage()));
     } catch (\Exception $e) {
         $this->_outputWriter->write(sprintf('<error>Migration %s failed during %s. Error %s</error>', $this->_version, $this->getExecutionState(), $e->getMessage()));
         $this->_connection->rollback();
         $this->_state = self::STATE_NONE;
         throw $e;
     }
     $this->_state = self::STATE_NONE;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:74,代码来源:Version.php

示例8: rollback

 public function rollback()
 {
     if ($this->_connection) {
         $this->_connection->rollback();
     }
 }
开发者ID:uwitec,项目名称:outbuying,代码行数:6,代码来源:Db.php

示例9: rollback

 /**
  * @see Connection::rollback()
  */
 public function rollback()
 {
     krumo('DBArrayConnection rollback ');
     die;
     $this->log("Rolling back transaction.");
     return $this->childConnection->rollback();
 }
开发者ID:emildev35,项目名称:processmaker,代码行数:10,代码来源:DBArrayConnection.php

示例10: importDataGuru

function importDataGuru($inputFileName, $idSekolah)
{
    try {
        /**  Identify the type of $inputFileName  **/
        $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
        /**  Create a new Reader of the type that has been identified  **/
        $objReader = PHPExcel_IOFactory::createReader($inputFileType);
        /**  Load $inputFileName to a PHPExcel Object  **/
        $objReader->setReadDataOnly(true);
        $objPHPExcel = $objReader->load($inputFileName);
    } catch (Exception $e) {
        die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
    }
    $worksheets;
    $conn;
    $nameSheet;
    $noRow = 0;
    try {
        $conn = new Connection();
        $conn->beginTransaction();
        $worksheets = $objPHPExcel->getAllSheets();
        $idGuru;
        foreach ($worksheets as $worksheet) {
            $nameSheet = $worksheet->getTitle();
            //guru
            $noRow = 2;
            while (true) {
                $username = $worksheet->getCell('B' . $noRow)->getCalculatedValue();
                $password = $worksheet->getCell('C' . $noRow)->getCalculatedValue();
                $nip = $worksheet->getCell('D' . $noRow)->getCalculatedValue();
                $nama = $worksheet->getCell('E' . $noRow)->getCalculatedValue();
                if ($username == null) {
                    break;
                }
                $idGuru = $conn->setGuru($nip, $nama, null, null, null, null, null, null, null, $username, $password, $idSekolah, null);
                //$idGuru=$conn->setGuru($nip, $nama, $tempatLahir, $tglLahir, $jk, $alamat, $telp, $hp, $email, $username, $password, $idSekolah, $foto);
                $noRow++;
            }
        }
        $conn->commit();
        echo 'Data import succesfully';
    } catch (Exception $e) {
        $conn->rollback();
        die('Error in Sheet ' . $nameSheet . ' row ' . $noRow . ' : ' . $e->getMessage());
    }
}
开发者ID:vicky125,项目名称:san_mar,代码行数:46,代码来源:reader.php


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