本文整理汇总了PHP中Doctrine\DBAL\Types\Type::GetType方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::GetType方法的具体用法?PHP Type::GetType怎么用?PHP Type::GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Types\Type
的用法示例。
在下文中一共展示了Type::GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTableTasks
function createTableTasks($schema)
{
try {
$table = $schema->createTable('tasks');
} catch (\Exception $e) {
$table = $schema->getTable('tasks');
}
$columns = [0 => 'task_id', 1 => 'task_type', 2 => 'task_payload', 3 => 'task_status', 4 => 'task_handle'];
foreach (array_keys($table->Getcolumns()) as $column) {
if (!in_array($column, $columns)) {
$table->dropColumn($column);
}
}
try {
$table->addColumn('task_id', 'integer', ['notnull' => false, 'autoincrement' => true, 'default' => NULL]);
} catch (\Exception $e) {
$column = $table->GetColumn('task_id');
$column->setType(Type::GetType('integer'));
}
try {
$table->addColumn('task_type', 'string', ['notnull' => false, 'length' => 40, 'default' => NULL]);
} catch (\Exception $e) {
$column = $table->GetColumn('task_type');
$column->setType(Type::GetType('string'));
}
try {
$table->addColumn('task_payload', 'text', ['notnull' => false, 'default' => NULL]);
} catch (\Exception $e) {
$column = $table->GetColumn('task_payload');
$column->setType(Type::GetType('text'));
}
try {
$table->addColumn('task_status', 'integer', ['notnull' => false, 'default' => 1]);
} catch (\Exception $e) {
$column = $table->GetColumn('task_status');
$column->setType(Type::GetType('integer'));
}
try {
$table->addColumn('task_handle', 'string', ['notnull' => false, 'length' => 20, 'default' => '']);
} catch (\Exception $e) {
$column = $table->GetColumn('task_handle');
$column->setType(Type::GetType('string'));
}
$table->setPrimaryKey([0 => 'task_id']);
$table->addIndex([0 => 'task_handle', 1 => 'task_status']);
$table->addIndex([0 => 'task_handle', 1 => 'task_type']);
}