本文整理汇总了PHP中SilverStripe\ORM\DB::table_list方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::table_list方法的具体用法?PHP DB::table_list怎么用?PHP DB::table_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SilverStripe\ORM\DB
的用法示例。
在下文中一共展示了DB::table_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTablesAreCreated
public function testTablesAreCreated()
{
$tables = DB::table_list();
$check = array('versionableextensionstest_dataobject_test1_live', 'versionableextensionstest_dataobject_test2_live', 'versionableextensionstest_dataobject_test3_live', 'versionableextensionstest_dataobject_test1_versions', 'versionableextensionstest_dataobject_test2_versions', 'versionableextensionstest_dataobject_test3_versions');
// Check that the right tables exist
foreach ($check as $tableName) {
$this->assertContains($tableName, array_keys($tables), 'Contains table: ' . $tableName);
}
}
示例2: testTableCaseFixed
public function testTableCaseFixed()
{
DB::quiet();
// Modify table case
DB::get_schema()->renameTable('DataObjectSchemaGenerationTest_DO', '__TEMP__DataOBJECTSchemaGenerationTest_do');
DB::get_schema()->renameTable('__TEMP__DataOBJECTSchemaGenerationTest_do', 'DataOBJECTSchemaGenerationTest_do');
// Check table
$tables = DB::table_list();
$this->assertEquals('DataOBJECTSchemaGenerationTest_do', $tables['dataobjectschemagenerationtest_do']);
// Rebuild table
DB::get_schema()->schemaUpdate(function () {
DataObjectSchemaGenerationTest_DO::singleton()->requireTable();
});
// Check table
$tables = DB::table_list();
$this->assertEquals('DataObjectSchemaGenerationTest_DO', $tables['dataobjectschemagenerationtest_do']);
}
示例3: testVersionedWithSingleStage
public function testVersionedWithSingleStage()
{
$tables = DB::table_list();
$this->assertContains('versionedtest_singlestage', array_keys($tables), 'Contains base table');
$this->assertContains('versionedtest_singlestage_versions', array_keys($tables), 'Contains versions table');
$this->assertNotContains('versionedtest_singlestage_live', array_keys($tables), 'Does not contain separate table with _Live suffix');
$this->assertNotContains('versionedtest_singlestage_stage', array_keys($tables), 'Does not contain separate table with _Stage suffix');
Versioned::set_stage(Versioned::DRAFT);
$obj = new VersionedTest_SingleStage(array('Name' => 'MyObj'));
$obj->write();
$this->assertNotNull(VersionedTest_SingleStage::get()->byID($obj->ID), 'Writes to and reads from default stage if its set explicitly');
Versioned::set_stage(Versioned::LIVE);
$obj = new VersionedTest_SingleStage(array('Name' => 'MyObj'));
$obj->write();
$this->assertNotNull(VersionedTest_SingleStage::get()->byID($obj->ID), 'Writes to and reads from default stage even if a non-matching stage is set');
}