| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | namespace Aurora\System\Db; |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | class Field |
| 19: | { |
| 20: | public const AUTO_INT = 10; |
| 21: | public const AUTO_INT_BIG = 11; |
| 22: | public const AUTO_INT_UNSIGNED = 12; |
| 23: | public const AUTO_INT_BIG_UNSIGNED = 13; |
| 24: | |
| 25: | public const BIT = 20; |
| 26: | public const INT = 21; |
| 27: | public const INT_SHORT = 22; |
| 28: | public const INT_SMALL = 23; |
| 29: | public const INT_BIG = 24; |
| 30: | public const INT_UNSIGNED = 25; |
| 31: | public const INT_SHORT_SMALL = 26; |
| 32: | public const INT_BIG_UNSIGNED = 27; |
| 33: | |
| 34: | public const CHAR = 31; |
| 35: | public const VAR_CHAR = 32; |
| 36: | public const TEXT = 33; |
| 37: | public const TEXT_MEDIUM = 37; |
| 38: | public const TEXT_LONG = 34; |
| 39: | public const BLOB = 35; |
| 40: | public const BLOB_LONG = 36; |
| 41: | |
| 42: | public const DATETIME = 40; |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | protected $sName; |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | protected $iType; |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | protected $mDefault; |
| 58: | |
| 59: | |
| 60: | |
| 61: | |
| 62: | protected $iCustomLen; |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | protected $bNotNullWithOutDefault; |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | |
| 75: | |
| 76: | public function __construct($sName, $iType, $mDefault = null, $iCustomLen = null, $bNotNullWithOutDefault = false) |
| 77: | { |
| 78: | $this->sName = $sName; |
| 79: | $this->iType = $iType; |
| 80: | $this->mDefault = $mDefault; |
| 81: | $this->iCustomLen = $iCustomLen; |
| 82: | $this->bNotNullWithOutDefault = $bNotNullWithOutDefault; |
| 83: | } |
| 84: | |
| 85: | |
| 86: | |
| 87: | |
| 88: | public function Name() |
| 89: | { |
| 90: | return $this->sName; |
| 91: | } |
| 92: | |
| 93: | |
| 94: | |
| 95: | |
| 96: | |
| 97: | |
| 98: | public function ToAlterString($sTableName, $oHelper) |
| 99: | { |
| 100: | return sprintf( |
| 101: | 'ALTER TABLE %s ADD %s', |
| 102: | $oHelper->EscapeColumn($sTableName), |
| 103: | $this->ToString($oHelper) |
| 104: | ); |
| 105: | } |
| 106: | |
| 107: | |
| 108: | |
| 109: | |
| 110: | public function ToString($oHelper) |
| 111: | { |
| 112: | return $oHelper->FieldToString($this->sName, $this->iType, $this->mDefault, $this->iCustomLen, $this->bNotNullWithOutDefault); |
| 113: | } |
| 114: | } |
| 115: | |