当前位置: 首页>>代码示例>>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;未经允许,请勿转载。