|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @link http://www.yiiframework.com/
|
|
|
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
|
|
|
* @license http://www.yiiframework.com/license/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace yii\db\oci;
|
|
|
|
|
refactored SchemaBuilder
- rename class to ColumnSchemaBuilder as this is more appropriate
- changed internal organisation to match how the rest of schema related classes work
- the ColumnSchemaBuilder is now created the same way as QueryBuilder is
- removed static call magic and method annotations, now real methods are called as they are
- the whole code works on objects in a db context now instead of setting database connection in global state
- trait is now used by Migration by default but can be used in other contexts as well
Migration usage is now as follows:
```php
$this->createTable('example_table', [
'id' => $this->primaryKey(),
'name' => $this->string(64)->notNull(),
'type' => $this->integer()->notNull()->defaultValue(10),
'description' => $this->text(),
'rule_name' => $this->string(64),
'data' => $this->text(),
'created_at' => $this->datetime()->notNull(),
'updated_at' => $this->datetime(),
]);
```
9 years ago
|
|
|
use yii\db\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
|
|
|
|
|
|
|
|
/**
|
refactored SchemaBuilder
- rename class to ColumnSchemaBuilder as this is more appropriate
- changed internal organisation to match how the rest of schema related classes work
- the ColumnSchemaBuilder is now created the same way as QueryBuilder is
- removed static call magic and method annotations, now real methods are called as they are
- the whole code works on objects in a db context now instead of setting database connection in global state
- trait is now used by Migration by default but can be used in other contexts as well
Migration usage is now as follows:
```php
$this->createTable('example_table', [
'id' => $this->primaryKey(),
'name' => $this->string(64)->notNull(),
'type' => $this->integer()->notNull()->defaultValue(10),
'description' => $this->text(),
'rule_name' => $this->string(64),
'data' => $this->text(),
'created_at' => $this->datetime()->notNull(),
'updated_at' => $this->datetime(),
]);
```
9 years ago
|
|
|
* ColumnSchemaBuilder is the schema builder for Oracle databases.
|
|
|
|
*
|
|
|
|
* @author Vasenin Matvey <vaseninm@gmail.com>
|
|
|
|
* @author Chris Harris <chris@buckshotsoftware.com>
|
|
|
|
* @since 2.0.6
|
|
|
|
*/
|
refactored SchemaBuilder
- rename class to ColumnSchemaBuilder as this is more appropriate
- changed internal organisation to match how the rest of schema related classes work
- the ColumnSchemaBuilder is now created the same way as QueryBuilder is
- removed static call magic and method annotations, now real methods are called as they are
- the whole code works on objects in a db context now instead of setting database connection in global state
- trait is now used by Migration by default but can be used in other contexts as well
Migration usage is now as follows:
```php
$this->createTable('example_table', [
'id' => $this->primaryKey(),
'name' => $this->string(64)->notNull(),
'type' => $this->integer()->notNull()->defaultValue(10),
'description' => $this->text(),
'rule_name' => $this->string(64),
'data' => $this->text(),
'created_at' => $this->datetime()->notNull(),
'updated_at' => $this->datetime(),
]);
```
9 years ago
|
|
|
class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
protected function buildUnsignedString()
|
|
|
|
{
|
|
|
|
return $this->isUnsigned ? ' UNSIGNED' : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
switch ($this->getTypeCategory()) {
|
|
|
|
case self::CATEGORY_PK:
|
|
|
|
$format = '{type}{length}{check}{append}';
|
|
|
|
break;
|
|
|
|
case self::CATEGORY_NUMERIC:
|
|
|
|
$format = '{type}{length}{unsigned}{default}{notnull}{check}{append}';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$format = '{type}{length}{default}{notnull}{check}{append}';
|
|
|
|
}
|
|
|
|
return $this->buildCompleteString($format);
|
|
|
|
}
|
|
|
|
}
|