當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Table::truncateSql方法代碼示例

本文整理匯總了PHP中Cake\Database\Schema\Table::truncateSql方法的典型用法代碼示例。如果您正苦於以下問題:PHP Table::truncateSql方法的具體用法?PHP Table::truncateSql怎麽用?PHP Table::truncateSql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\Database\Schema\Table的用法示例。


在下文中一共展示了Table::truncateSql方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: truncate

 /**
  * {@inheritDoc}
  */
 public function truncate(ConnectionInterface $db)
 {
     $sql = $this->_schema->truncateSql($db);
     foreach ($sql as $stmt) {
         $db->execute($stmt)->closeCursor();
     }
     return true;
 }
開發者ID:taodf,項目名稱:cakephp,代碼行數:11,代碼來源:TestFixture.php

示例2: testTruncateSql

 /**
  * Test truncateSql()
  *
  * @return void
  */
 public function testTruncateSql()
 {
     $driver = $this->_getMockedDriver();
     $connection = $this->getMockBuilder('Cake\\Database\\Connection')->disableOriginalConstructor()->getMock();
     $connection->expects($this->any())->method('driver')->will($this->returnValue($driver));
     $table = new Table('schema_articles');
     $table->addColumn('id', 'integer')->addConstraint('primary', ['type' => 'primary', 'columns' => ['id']]);
     $result = $table->truncateSql($connection);
     $this->assertCount(1, $result);
     $this->assertEquals('TRUNCATE "schema_articles" RESTART IDENTITY CASCADE', $result[0]);
 }
開發者ID:rashmi,項目名稱:newrepo,代碼行數:16,代碼來源:PostgresSchemaTest.php

示例3: testTruncateSqlNoSequences

 /**
  * Test truncateSql() with no sequences
  *
  * @return void
  */
 public function testTruncateSqlNoSequences()
 {
     $driver = $this->_getMockedDriver();
     $connection = $this->getMock('Cake\\Database\\Connection', [], [], '', false);
     $connection->expects($this->any())->method('driver')->will($this->returnValue($driver));
     $statement = $this->getMock('\\PDOStatement', ['execute', 'rowCount', 'closeCursor', 'fetch']);
     $driver->connection()->expects($this->once())->method('prepare')->with('SELECT 1 FROM sqlite_master WHERE name = "sqlite_sequence"')->will($this->returnValue($statement));
     $statement->expects($this->once())->method('fetch')->will($this->returnValue(false));
     $table = new Table('articles');
     $result = $table->truncateSql($connection);
     $this->assertCount(1, $result);
     $this->assertEquals('DELETE FROM "articles"', $result[0]);
 }
開發者ID:maitrepylos,項目名稱:nazeweb,代碼行數:18,代碼來源:SqliteSchemaTest.php

示例4: testTruncateSql

 /**
  * Test truncateSql()
  *
  * @return void
  */
 public function testTruncateSql()
 {
     $driver = $this->_getMockedDriver();
     $connection = $this->getMockBuilder('Cake\\Database\\Connection')->disableOriginalConstructor()->getMock();
     $connection->expects($this->any())->method('driver')->will($this->returnValue($driver));
     $table = new Table('articles');
     $result = $table->truncateSql($connection);
     $this->assertCount(1, $result);
     $this->assertEquals('TRUNCATE TABLE `articles`', $result[0]);
 }
開發者ID:rashmi,項目名稱:newrepo,代碼行數:15,代碼來源:MysqlSchemaTest.php

示例5: testTruncateSql

 /**
  * Test truncateSql()
  *
  * @return void
  */
 public function testTruncateSql()
 {
     $driver = $this->_getMockedDriver();
     $connection = $this->getMock('Cake\\Database\\Connection', [], [], '', false);
     $connection->expects($this->any())->method('driver')->will($this->returnValue($driver));
     $table = new Table('schema_articles');
     $table->addColumn('id', 'integer')->addConstraint('primary', ['type' => 'primary', 'columns' => ['id']]);
     $result = $table->truncateSql($connection);
     $this->assertCount(2, $result);
     $this->assertEquals('DELETE FROM [schema_articles]', $result[0]);
     $this->assertEquals('DBCC CHECKIDENT([schema_articles], RESEED, 0)', $result[1]);
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:17,代碼來源:SqlserverSchemaTest.php


注:本文中的Cake\Database\Schema\Table::truncateSql方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。