您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

72 行
1.7KB

  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\db\mysql;
  8. use yii\db\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
  9. /**
  10. * ColumnSchemaBuilder is the schema builder for MySQL databases.
  11. *
  12. * @author Chris Harris <chris@buckshotsoftware.com>
  13. * @since 2.0.8
  14. */
  15. class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
  16. {
  17. /**
  18. * @inheritdoc
  19. */
  20. protected function buildUnsignedString()
  21. {
  22. return $this->isUnsigned ? ' UNSIGNED' : '';
  23. }
  24. /**
  25. * @inheritdoc
  26. */
  27. protected function buildAfterString()
  28. {
  29. return $this->after !== null ?
  30. ' AFTER ' . $this->db->quoteColumnName($this->after) :
  31. '';
  32. }
  33. /**
  34. * @inheritdoc
  35. */
  36. protected function buildFirstString()
  37. {
  38. return $this->isFirst ? ' FIRST' : '';
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. protected function buildCommentString()
  44. {
  45. return $this->comment !== null ? ' COMMENT ' . $this->db->quoteValue($this->comment) : '';
  46. }
  47. /**
  48. * @inheritdoc
  49. */
  50. public function __toString()
  51. {
  52. switch ($this->getTypeCategory()) {
  53. case self::CATEGORY_PK:
  54. $format = '{type}{length}{check}{comment}{pos}{append}';
  55. break;
  56. case self::CATEGORY_NUMERIC:
  57. $format = '{type}{length}{unsigned}{notnull}{unique}{default}{check}{comment}{pos}{append}';
  58. break;
  59. default:
  60. $format = '{type}{length}{notnull}{unique}{default}{check}{comment}{pos}{append}';
  61. }
  62. return $this->buildCompleteString($format);
  63. }
  64. }