本文整理汇总了PHP中Migration::tables方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::tables方法的具体用法?PHP Migration::tables怎么用?PHP Migration::tables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::tables方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: migration
/**
* To Perform migration to ensure the table and its properties
* are up-to-date
*
*/
public static function migration()
{
$tables = Migration::tables();
// Simple Filters.
if (!isset($tables)) {
return false;
}
foreach ($tables as $key => $value) {
if (empty($value) || is_null($value) || !isset($value)) {
continue;
}
loop:
if (Capsule::Schema()->hasTable($key)) {
foreach ($value as $column => $datatype) {
if (!Capsule::Schema()->hasColumn($key, $column)) {
//Assign the Name and Datatype for temporary access
self::$columns['name'] = $column;
self::$columns['datatype'] = $datatype;
Capsule::Schema()->table($key, function ($table) {
$column = self::$columns['name'];
$datatype = self::$columns['datatype'];
$table->{$datatype}($column)->after('id');
});
}
}
} else {
Capsule::schema()->create($key, function ($table) {
$table->increments('id');
$table->timestamps();
});
goto loop;
}
}
}
示例2: testInitializeAndPopulate
/**
* Test initialization and population of tables
*/
public function testInitializeAndPopulate()
{
$migration = new Migration();
$migration->tables(array('ut_init', 'ut_pop'));
$result = $migration->initialize(TRUE);
$this->assertEquals(2, count($result));
$this->assertEquals(1, $result['ut_init']);
$this->assertEquals(2, $result['ut_pop']);
$database = Database::instance();
$this->assertRegExp('/testName_1/', $database->queries[2]);
$this->assertRegExp('/someName_2/', $database->queries[2]);
}