本文整理匯總了PHP中DboSource::dropSchema方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::dropSchema方法的具體用法?PHP DboSource::dropSchema怎麽用?PHP DboSource::dropSchema使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DboSource
的用法示例。
在下文中一共展示了DboSource::dropSchema方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testDropSchemaNoSchema
/**
* testDropSchemaNoSchema method
*
* @expectedException PHPUnit_Framework_Error
* @throws PHPUnit_Framework_Error
* @return void
*/
public function testDropSchemaNoSchema()
{
try {
$this->Dbo->dropSchema(null);
} catch (Throwable $t) {
throw new PHPUnit_Framework_Error($t);
}
}
示例2: getDropSql
/**
* sql drop statement
*
* @param $datasource
* @param $tablename
* @param $exclude_missing_tables
* @return string
*/
function getDropSql($datasource, $tablename = null, $exclude_missing_tables = false)
{
if (!$this->_checkCurrentDatasource($datasource)) {
$this->_setupDataSource();
}
$this->Schema->tables = $this->_getProcessTables($tablename, $exclude_missing_tables);
$sql = $this->DataSource->dropSchema($this->Schema);
return $this->out($sql);
}
示例3: testSchema
/**
* testSchema method
*
* @access public
* @return void
*/
public function testSchema()
{
$Schema = new CakeSchema();
$Schema->tables = array('table' => array(), 'anotherTable' => array());
$this->expectError();
$result = $this->Dbo->dropSchema(null);
$this->assertTrue($result === null);
$result = $this->Dbo->dropSchema($Schema, 'non_existing');
$this->assertTrue(empty($result));
$result = $this->Dbo->dropSchema($Schema, 'table');
$this->assertPattern('/^\\s*DROP TABLE IF EXISTS\\s+' . $this->Dbo->fullTableName('table') . ';\\s*$/s', $result);
}
示例4: dropTable
/**
* Drop an existing table.
*
* @param string $table
* @throws MissingTableException if the table does not exists in the database
* @throws MigrationException if an sql error occurred
* @return Migration
*/
public function dropTable($table)
{
if (!in_array($this->_db->fullTableName($table, false, false), $this->_db->listSources())) {
throw new MissingTableException(__d('migration', 'Table "%s" does not exist in database.', $this->_db->fullTableName($table, false, false)));
}
$this->_schema->tables = array($table => array());
try {
$this->_db->execute($this->_db->dropSchema($this->_schema));
} catch (Exception $e) {
throw new MigrationException(__d('migration', 'SQL Error: %s', $e->getMessage()));
}
return $this;
}
示例5: _dropTable
/**
* Drop Table method
*
* @param string $type Type of operation to be done, in this case 'drop_table'
* @param array $tables List of tables to be dropped
* @return boolean Return true in case of success, otherwise false
* @throws MigrationException
*/
protected function _dropTable($type, $tables)
{
foreach ($tables as $table) {
$this->Schema->tables = array($table => array());
if ($this->_invokePrecheck('beforeAction', 'drop_table', array('table' => $table))) {
$this->_invokeCallbacks('beforeAction', 'drop_table', array('table' => $table));
if (@$this->db->execute($this->db->dropSchema($this->Schema)) === false) {
throw new MigrationException($this, sprintf(__d('migrations', 'SQL Error: %s'), $this->db->error));
}
$this->_invokeCallbacks('afterAction', 'drop_table', array('table' => $table));
}
}
return true;
}
示例6: testAlterIndexes
/**
* Test the alter index capabilities of postgres
*
* @return void
*/
public function testAlterIndexes()
{
$this->Dbo->cacheSources = false;
$schema1 = new CakeSchema(array('name' => 'AlterTest1', 'connection' => 'test', 'altertest' => array('id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50), 'group1' => array('type' => 'integer', 'null' => true), 'group2' => array('type' => 'integer', 'null' => true))));
$this->Dbo->rawQuery($this->Dbo->createSchema($schema1));
$schema2 = new CakeSchema(array('name' => 'AlterTest2', 'connection' => 'test', 'altertest' => array('id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50), 'group1' => array('type' => 'integer', 'null' => true), 'group2' => array('type' => 'integer', 'null' => true), 'indexes' => array('name_idx' => array('unique' => false, 'column' => 'name'), 'group_idx' => array('unique' => false, 'column' => 'group1'), 'compound_idx' => array('unique' => false, 'column' => array('group1', 'group2')), 'PRIMARY' => array('unique' => true, 'column' => 'id')))));
$this->Dbo->query($this->Dbo->alterSchema($schema2->compare($schema1)));
$indexes = $this->Dbo->index('altertest');
$this->assertEquals($schema2->tables['altertest']['indexes'], $indexes);
// Change three indexes, delete one and add another one
$schema3 = new CakeSchema(array('name' => 'AlterTest3', 'connection' => 'test', 'altertest' => array('id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50), 'group1' => array('type' => 'integer', 'null' => true), 'group2' => array('type' => 'integer', 'null' => true), 'indexes' => array('name_idx' => array('unique' => true, 'column' => 'name'), 'group_idx' => array('unique' => false, 'column' => 'group2'), 'compound_idx' => array('unique' => false, 'column' => array('group2', 'group1')), 'another_idx' => array('unique' => false, 'column' => array('group1', 'name'))))));
$this->Dbo->query($this->Dbo->alterSchema($schema3->compare($schema2)));
$indexes = $this->Dbo->index('altertest');
$this->assertEquals($schema3->tables['altertest']['indexes'], $indexes);
// Compare us to ourself.
$this->assertEquals(array(), $schema3->compare($schema3));
// Drop the indexes
$this->Dbo->query($this->Dbo->alterSchema($schema1->compare($schema3)));
$indexes = $this->Dbo->index('altertest');
$this->assertEquals(array(), $indexes);
$this->Dbo->query($this->Dbo->dropSchema($schema1));
}
示例7: testDropSchemaNoSchema
/**
* testDropSchemaNoSchema method
*
* @expectedException PHPUnit_Framework_Error
* @return void
*/
public function testDropSchemaNoSchema()
{
$result = $this->Dbo->dropSchema(null);
}
示例8: drop
/**
* Run after all tests executed, should return SQL statement to drop table for this fixture.
*
* @param DboSource $db An instance of the database object used to create the fixture table
* @return bool True on success, false on failure
*/
public function drop($db)
{
if (empty($this->fields)) {
return false;
}
$this->Schema->build(array($this->table => $this->fields));
try {
$db->execute($db->dropSchema($this->Schema), array('log' => false));
$this->created = array_diff($this->created, array($db->configKeyName));
} catch (Exception $e) {
return false;
}
return true;
}
示例9: testDropSchemaNoSchema
/**
* testDropSchemaNoSchema method
*
* @expectedException PHPUnit_Framework_Error
* @return void
*/
public function testDropSchemaNoSchema()
{
$this->Dbo->dropSchema(NULL);
}