allowsCascading() 공개 메소드

Returns true if the connection allows cascading
public allowsCascading ( ) : boolean
리턴 boolean
예제 #1
0
파일: Truncate.php 프로젝트: pdkhuong/BBG
 public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
 {
     foreach ($dataSet->getReverseIterator() as $table) {
         /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
         $query = "\n                {$connection->getTruncateCommand()} {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}\n            ";
         if ($this->useCascade && $connection->allowsCascading()) {
             $query .= " CASCADE";
         }
         try {
             $connection->getConnection()->query($query);
         } catch (PDOException $e) {
             throw new PHPUnit_Extensions_Database_Operation_Exception('TRUNCATE', $query, array(), $table, $e->getMessage());
         }
     }
 }
예제 #2
0
 public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
 {
     foreach ($dataSet->getReverseIterator() as $table) {
         /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
         $query = "\n                {$connection->getTruncateCommand()} {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}\n            ";
         if ($this->useCascade && $connection->allowsCascading()) {
             $query .= ' CASCADE';
         }
         try {
             $this->disableForeignKeyChecksForMysql($connection);
             $connection->getConnection()->query($query);
             $this->enableForeignKeyChecksForMysql($connection);
         } catch (\Exception $e) {
             $this->enableForeignKeyChecksForMysql($connection);
             if ($e instanceof PDOException) {
                 throw new PHPUnit_Extensions_Database_Operation_Exception('TRUNCATE', $query, [], $table, $e->getMessage());
             }
             throw $e;
         }
     }
 }
예제 #3
0
 public function __construct(IDatabaseConnection $connection)
 {
     $this->connection = $connection;
     $this->setUpOperation = new \PHPUnit_Extensions_Database_Operation_Composite(array(new Operations\Truncate($connection->allowsCascading()), OperationFactory::INSERT()));
     $this->tearDownOperation = OperationFactory::NONE();
 }