選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ColumnSchemaBuilder.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. }