クラス yii\db\oci\ColumnSchemaBuilder
ColumnSchemaBuilder は、Oracle データベース用のスキーマビルダーです。
公開プロパティ
プロパティ | 型 | 説明 | 定義元 |
---|---|---|---|
$after | string | この列が追加される列の後。 | yii\db\ColumnSchemaBuilder |
$append | mixed | 列スキーマ定義に追加される SQL 文字列。 | yii\db\ColumnSchemaBuilder |
$categoryMap | array | 抽象列タイプ(キー)からタイプカテゴリ(値)へのマッピング。 | yii\db\ColumnSchemaBuilder |
$check | string | 列の CHECK 制約。 |
yii\db\ColumnSchemaBuilder |
$comment | string | 列のコメント値。 | yii\db\ColumnSchemaBuilder |
$db | yii\db\Connection | 現在のデータベース接続。 | yii\db\ColumnSchemaBuilder |
$default | mixed | 列のデフォルト値。 | yii\db\ColumnSchemaBuilder |
$isFirst | boolean | この列をテーブルの先頭に挿入するかどうか。 | yii\db\ColumnSchemaBuilder |
$isNotNull | boolean|null | 列が NULL 可能かどうか。 | yii\db\ColumnSchemaBuilder |
$isUnique | boolean | 列の値が一意である必要があるかどうか。 | yii\db\ColumnSchemaBuilder |
$isUnsigned | boolean | 列の値が符号なしである必要があるかどうか。 | yii\db\ColumnSchemaBuilder |
$length | integer|string|array | 列のサイズまたは精度定義。 | yii\db\ColumnSchemaBuilder |
$type | string | INTEGER、VARCHAR、DATETIME などの列タイプ定義。 | yii\db\ColumnSchemaBuilder |
$typeCategoryMap | array | 抽象列タイプ(キー)からタイプカテゴリ(値)へのマッピング。 | yii\db\ColumnSchemaBuilder |
公開メソッド
保護されたメソッド
メソッド | 説明 | 定義元 |
---|---|---|
buildAfterString() | 列の後の制約を構築します。デフォルトはサポートされていません。 | yii\db\ColumnSchemaBuilder |
buildAppendString() | 列定義に追加されるカスタム文字列を構築します。 | yii\db\ColumnSchemaBuilder |
buildCheckString() | 列のチェック制約を構築します。 | yii\db\ColumnSchemaBuilder |
buildCommentString() | 列のコメント仕様を構築します。 | yii\db\ColumnSchemaBuilder |
buildCompleteString() | 入力形式から完全な列定義を返します。 | yii\db\ColumnSchemaBuilder |
buildDefaultString() | 列のデフォルト値の仕様を構築します。 | yii\db\ColumnSchemaBuilder |
buildDefaultValue() | 列のデフォルト値を返します。 | yii\db\ColumnSchemaBuilder |
buildFirstString() | 列の最初の制約を構築します。デフォルトはサポートされていません。 | yii\db\ColumnSchemaBuilder |
buildLengthString() | 列の長さ/精度部分を構築します。 | yii\db\ColumnSchemaBuilder |
buildNotNullString() | 列の NOT NULL 制約を構築します。 | yii\db\ColumnSchemaBuilder |
buildUniqueString() | 列の一意制約を構築します。 | yii\db\ColumnSchemaBuilder |
buildUnsignedString() | 列の符号なし文字列を構築します。デフォルトはサポートされていません。 | yii\db\oci\ColumnSchemaBuilder |
getTypeCategory() | 列タイプのカテゴリを返します。 | yii\db\ColumnSchemaBuilder |
定数
定数 | 値 | 説明 | 定義元 |
---|---|---|---|
CATEGORY_NUMERIC | 'numeric' | yii\db\ColumnSchemaBuilder | |
CATEGORY_OTHER | 'other' | yii\db\ColumnSchemaBuilder | |
CATEGORY_PK | 'pk' | yii\db\ColumnSchemaBuilder | |
CATEGORY_STRING | 'string' | yii\db\ColumnSchemaBuilder | |
CATEGORY_TIME | 'time' | yii\db\ColumnSchemaBuilder |
メソッドの詳細
定義元: yii\base\BaseObject::__call()
クラスメソッドではない名前付きメソッドを呼び出します。
不明なメソッドが呼び出されたときに暗黙的に呼び出される PHP マジックメソッドであるため、このメソッドを直接呼び出さないでください。
public mixed __call ( $name, $params ) | ||
$name | string |
メソッド名 |
$params | array |
メソッドのパラメータ |
return | mixed |
メソッドの戻り値 |
---|---|---|
throws | yii\base\UnknownMethodException |
不明なメソッドを呼び出すとき |
public function __call($name, $params)
{
throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}
定義元: yii\db\ColumnSchemaBuilder::__construct()
タイプと値の精度を指定して、列スキーマビルダーのインスタンスを作成します。
public void __construct ( $type, $length = null, $db = null, $config = [] ) | ||
$type | string |
カラムの型。$type を参照してください。 |
$length | integer|string|array|null |
カラムの長さまたは精度。$length を参照してください。 |
$db | yii\db\Connection|null |
現在のデータベース接続。$db を参照してください。 |
$config | array |
オブジェクトのプロパティを初期化するために使用される名前と値のペア |
public function __construct($type, $length = null, $db = null, $config = [])
{
$this->type = $type;
$this->length = $length;
$this->db = $db;
parent::__construct($config);
}
定義元: yii\base\BaseObject::__get()
オブジェクトプロパティの値を返します。
$value = $object->property;
の実行時に暗黙的に呼び出されるPHPのマジックメソッドであるため、このメソッドを直接呼び出さないでください。
__set() も参照してください。
public mixed __get ( $name ) | ||
$name | string |
プロパティ名 |
return | mixed |
プロパティの値 |
---|---|---|
throws | yii\base\UnknownPropertyException |
プロパティが定義されていない場合 |
throws | yii\base\InvalidCallException |
プロパティが書き込み専用の場合 |
public function __get($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) {
return $this->$getter();
} elseif (method_exists($this, 'set' . $name)) {
throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
}
throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}
定義元: yii\base\BaseObject::__isset()
プロパティが設定されているかどうか、つまり定義されており null ではないかどうかを確認します。
isset($object->property)
の実行時に暗黙的に呼び出されるPHPのマジックメソッドであるため、このメソッドを直接呼び出さないでください。
プロパティが定義されていない場合、falseが返されることに注意してください。
public boolean __isset ( $name ) | ||
$name | string |
プロパティ名またはイベント名 |
return | boolean |
指定されたプロパティが設定されているかどうか (nullでないかどうか)。 |
---|
public function __isset($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) {
return $this->$getter() !== null;
}
return false;
}
定義元: yii\base\BaseObject::__set()
オブジェクトプロパティの値を設定します。
$object->property = $value;
の実行時に暗黙的に呼び出されるPHPのマジックメソッドであるため、このメソッドを直接呼び出さないでください。
__get() も参照してください。
public void __set ( $name, $value ) | ||
$name | string |
プロパティ名またはイベント名 |
$value | mixed |
プロパティの値 |
throws | yii\base\UnknownPropertyException |
プロパティが定義されていない場合 |
---|---|---|
throws | yii\base\InvalidCallException |
プロパティが読み取り専用の場合 |
public function __set($name, $value)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) {
$this->$setter($value);
} elseif (method_exists($this, 'get' . $name)) {
throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
} else {
throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
}
}
列のスキーマの完全な文字列を構築します。
public string __toString ( ) |
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);
}
定義元: yii\base\BaseObject::__unset()
オブジェクトプロパティを null に設定します。
unset($object->property)
の実行時に暗黙的に呼び出されるPHPのマジックメソッドであるため、このメソッドを直接呼び出さないでください。
プロパティが定義されていない場合、このメソッドは何もしません。プロパティが読み取り専用の場合、例外がスローされます。
public void __unset ( $name ) | ||
$name | string |
プロパティ名 |
throws | yii\base\InvalidCallException |
プロパティが読み取り専用の場合。 |
---|
public function __unset($name)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) {
$this->$setter(null);
} elseif (method_exists($this, 'get' . $name)) {
throw new InvalidCallException('Unsetting read-only property: ' . get_class($this) . '::' . $name);
}
}
public $this after ( $after ) | ||
$after | string |
このカラムが追加されるカラムの後ろの指定。 |
public function after($after)
{
$this->after = $after;
return $this;
}
定義元: yii\db\ColumnSchemaBuilder::append()
列定義に追加する追加の SQL を指定します。
位置修飾子は、それらをサポートするデータベースのカラム定義の後に追加されます。
public $this append ( $sql ) | ||
$sql | string |
追加されるSQL文字列。 |
public function append($sql)
{
$this->append = $sql;
return $this;
}
定義元: yii\db\ColumnSchemaBuilder::buildAfterString()
列の後の制約を構築します。デフォルトはサポートされていません。
protected string buildAfterString ( ) | ||
return | string |
AFTER制約を含む文字列。 |
---|
protected function buildAfterString()
{
return '';
}
定義元: yii\db\ColumnSchemaBuilder::buildAppendString()
列定義に追加されるカスタム文字列を構築します。
protected string buildAppendString ( ) | ||
return | string |
追加するカスタム文字列。 |
---|
protected function buildAppendString()
{
return $this->append !== null ? ' ' . $this->append : '';
}
定義元: yii\db\ColumnSchemaBuilder::buildCheckString()
列のチェック制約を構築します。
protected string buildCheckString ( ) | ||
return | string |
CHECK制約を含む文字列。 |
---|
protected function buildCheckString()
{
return $this->check !== null ? " CHECK ({$this->check})" : '';
}
定義元: yii\db\ColumnSchemaBuilder::buildCommentString()
列のコメント仕様を構築します。
protected string buildCommentString ( ) | ||
return | string |
COMMENTキーワードとコメント自体を含む文字列。 |
---|
protected function buildCommentString()
{
return '';
}
定義元: yii\db\ColumnSchemaBuilder::buildCompleteString()
入力形式から完全な列定義を返します。
protected string buildCompleteString ( $format ) | ||
$format | string |
定義のフォーマット。 |
return | string |
完全なカラム定義を含む文字列。 |
---|
protected function buildCompleteString($format)
{
$placeholderValues = [
'{type}' => $this->type,
'{length}' => $this->buildLengthString(),
'{unsigned}' => $this->buildUnsignedString(),
'{notnull}' => $this->buildNotNullString(),
'{unique}' => $this->buildUniqueString(),
'{default}' => $this->buildDefaultString(),
'{check}' => $this->buildCheckString(),
'{comment}' => $this->buildCommentString(),
'{pos}' => $this->isFirst ? $this->buildFirstString() : $this->buildAfterString(),
'{append}' => $this->buildAppendString(),
];
return strtr($format, $placeholderValues);
}
定義元: yii\db\ColumnSchemaBuilder::buildDefaultString()
列のデフォルト値の仕様を構築します。
protected string buildDefaultString ( ) | ||
return | string |
カラムのデフォルト値を持つ文字列。 |
---|
protected function buildDefaultString()
{
$defaultValue = $this->buildDefaultValue();
if ($defaultValue === null) {
return '';
}
return ' DEFAULT ' . $defaultValue;
}
定義元: yii\db\ColumnSchemaBuilder::buildDefaultValue()
列のデフォルト値を返します。
protected string|null buildDefaultValue ( ) | ||
return | string|null |
カラムのデフォルト値を持つ文字列。 |
---|
protected function buildDefaultValue()
{
if ($this->default === null) {
return $this->isNotNull === false ? 'NULL' : null;
}
switch (gettype($this->default)) {
case 'double':
// ensure type cast always has . as decimal separator in all locales
$defaultValue = StringHelper::floatToString($this->default);
break;
case 'boolean':
$defaultValue = $this->default ? 'TRUE' : 'FALSE';
break;
case 'integer':
case 'object':
$defaultValue = (string) $this->default;
break;
default:
$defaultValue = "'{$this->default}'";
}
return $defaultValue;
}
定義元: yii\db\ColumnSchemaBuilder::buildFirstString()
列の最初の制約を構築します。デフォルトはサポートされていません。
protected string buildFirstString ( ) | ||
return | string |
FIRST制約を含む文字列。 |
---|
protected function buildFirstString()
{
return '';
}
定義元: yii\db\ColumnSchemaBuilder::buildLengthString()
列の長さ/精度部分を構築します。
protected string buildLengthString ( ) |
protected function buildLengthString()
{
if ($this->length === null || $this->length === []) {
return '';
}
if (is_array($this->length)) {
$this->length = implode(',', $this->length);
}
return "({$this->length})";
}
定義元: yii\db\ColumnSchemaBuilder::buildNotNullString()
列の NOT NULL 制約を構築します。
protected string buildNotNullString ( ) | ||
return | string |
$isNotNull が true の場合は 'NOT NULL' を、$isNotNull が false の場合は 'NULL' を、それ以外の場合は空文字列を返します。 |
---|
protected function buildNotNullString()
{
if ($this->isNotNull === true) {
return ' NOT NULL';
} elseif ($this->isNotNull === false) {
return ' NULL';
}
return '';
}
定義元: yii\db\ColumnSchemaBuilder::buildUniqueString()
列の一意制約を構築します。
protected string buildUniqueString ( ) | ||
return | string |
$isUnique が true の場合は 'UNIQUE' という文字列を返し、それ以外の場合は空文字列を返します。 |
---|
protected function buildUniqueString()
{
return $this->isUnique ? ' UNIQUE' : '';
}
列の符号なし文字列を構築します。デフォルトはサポートされていません。
protected string buildUnsignedString ( ) | ||
return | string |
UNSIGNEDキーワードを含む文字列。 |
---|
protected function buildUnsignedString()
{
return $this->isUnsigned ? ' UNSIGNED' : '';
}
定義元: yii\base\BaseObject::canGetProperty()
プロパティが読み取り可能かどうかを示す値を返します。
プロパティが読み取り可能になるのは、
- クラスが指定された名前に関連付けられたゲッターメソッドを持つ場合(この場合、プロパティ名は大小文字を区別しません)。
- クラスが指定された名前のメンバー変数を持つ場合 (
$checkVars
が true の場合)。
canSetProperty()も参照してください。
public boolean canGetProperty ( $name, $checkVars = true ) | ||
$name | string |
プロパティ名 |
$checkVars | boolean |
メンバー変数をプロパティとして扱うかどうか。 |
return | boolean |
プロパティが読み取り可能かどうか。 |
---|
public function canGetProperty($name, $checkVars = true)
{
return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name);
}
定義元: yii\base\BaseObject::canSetProperty()
プロパティが設定可能かどうかを示す値を返します。
プロパティが書き込み可能になるのは、
- クラスが指定された名前に関連付けられたセッターメソッドを持つ場合(この場合、プロパティ名は大小文字を区別しません)。
- クラスが指定された名前のメンバー変数を持つ場合 (
$checkVars
が true の場合)。
canGetProperty()も参照してください。
public boolean canSetProperty ( $name, $checkVars = true ) | ||
$name | string |
プロパティ名 |
$checkVars | boolean |
メンバー変数をプロパティとして扱うかどうか。 |
return | boolean |
プロパティが書き込み可能かどうか。 |
---|
public function canSetProperty($name, $checkVars = true)
{
return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name);
}
定義場所: yii\db\ColumnSchemaBuilder::check()
列の CHECK
制約を設定します。
public $this check ( $check ) | ||
$check | string |
追加される |
public function check($check)
{
$this->check = $check;
return $this;
}
::class
を使用してください。
定義場所: yii\base\BaseObject::className()
このクラスの完全修飾名を返します。
public static string className ( ) | ||
return | string |
このクラスの完全修飾名。 |
---|
public static function className()
{
return get_called_class();
}
定義場所: yii\db\ColumnSchemaBuilder::comment()
列のコメントを指定します。
public $this comment ( $comment ) | ||
$comment | string |
コメント |
public function comment($comment)
{
$this->comment = $comment;
return $this;
}
定義場所: yii\db\ColumnSchemaBuilder::defaultExpression()
列のデフォルトの SQL 式を指定します。
public $this defaultExpression ( $default ) | ||
$default | string |
デフォルト値の式。 |
public function defaultExpression($default)
{
$this->default = new Expression($default);
return $this;
}
定義場所: yii\db\ColumnSchemaBuilder::defaultValue()
列のデフォルト値を指定します。
public $this defaultValue ( $default ) | ||
$default | mixed |
デフォルト値。 |
public function defaultValue($default)
{
if ($default === null) {
$this->null();
}
$this->default = $default;
return $this;
}
public array getCategoryMap ( ) | ||
return | array |
抽象列タイプ(キー)からタイプカテゴリ(値)へのマッピング。 |
---|
public function getCategoryMap()
{
return static::$typeCategoryMap;
}
定義場所: yii\db\ColumnSchemaBuilder::getTypeCategory()
列タイプのカテゴリを返します。
protected string getTypeCategory ( ) | ||
return | string |
カラム型のカテゴリ名を含む文字列。 |
---|
protected function getTypeCategory()
{
return isset($this->categoryMap[$this->type]) ? $this->categoryMap[$this->type] : null;
}
定義場所: yii\base\BaseObject::hasMethod()
メソッドが定義されているかどうかを示す値を返します。
デフォルトの実装はPHP関数method_exists()
の呼び出しです。PHPのマジックメソッド__call()
を実装した場合は、このメソッドをオーバーライドできます。
public boolean hasMethod ( $name ) | ||
$name | string |
メソッド名 |
return | boolean |
メソッドが定義されているかどうか |
---|
public function hasMethod($name)
{
return method_exists($this, $name);
}
定義場所: yii\base\BaseObject::hasProperty()
プロパティが定義されているかどうかを示す値を返します。
プロパティは以下の場合に定義されます。
- クラスに指定された名前に関連付けられたゲッターまたはセッターメソッドがある場合(この場合、プロパティ名は大小文字を区別しません)。
- クラスが指定された名前のメンバー変数を持つ場合 (
$checkVars
が true の場合)。
参照
public boolean hasProperty ( $name, $checkVars = true ) | ||
$name | string |
プロパティ名 |
$checkVars | boolean |
メンバー変数をプロパティとして扱うかどうか。 |
return | boolean |
プロパティが定義されているかどうか |
---|
public function hasProperty($name, $checkVars = true)
{
return $this->canGetProperty($name, $checkVars) || $this->canSetProperty($name, false);
}
public void init ( ) |
public function init()
{
}
定義場所: yii\db\ColumnSchemaBuilder::notNull()
列に NOT NULL
制約を追加します。
public $this notNull ( ) |
public function notNull()
{
$this->isNotNull = true;
return $this;
}
定義場所: yii\db\ColumnSchemaBuilder::null()
列に NULL
制約を追加します。
public $this null ( ) |
public function null()
{
$this->isNotNull = false;
return $this;
}
public void setCategoryMap ( $categoryMap ) | ||
$categoryMap | array |
抽象列タイプ(キー)からタイプカテゴリ(値)へのマッピング。 |
public function setCategoryMap($categoryMap)
{
static::$typeCategoryMap = $categoryMap;
}
定義元: yii\db\ColumnSchemaBuilder::unique()
列に UNIQUE
制約を追加します。
public $this unique ( ) |
public function unique()
{
$this->isUnique = true;
return $this;
}
定義元: yii\db\ColumnSchemaBuilder::unsigned()
列を符号なしとしてマークします。
public $this unsigned ( ) |
public function unsigned()
{
switch ($this->type) {
case Schema::TYPE_PK:
$this->type = Schema::TYPE_UPK;
break;
case Schema::TYPE_BIGPK:
$this->type = Schema::TYPE_UBIGPK;
break;
}
$this->isUnsigned = true;
return $this;
}
サインアップ または ログイン してコメントしてください。