本文整理匯總了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']);
}