【问题标题】:How to set the default value of an integer field to it's possible maximum?如何将整数字段的默认值设置为可能的最大值?
【发布时间】:2016-12-03 08:57:13
【问题描述】:

有没有办法将最大值设置为整数字段的默认值?换句话说,我正在寻找一种简单而优雅的方法来替换下面代码中硬编码的999 值。

Schema::create('files', function(Blueprint $table)
{
    // . . .
    $table->integer('display_order')->default(999); // <-- MAX_VALUE instead of 999
    // . . .
});

【问题讨论】:

    标签: laravel laravel-5 laravel-migrations laravel-schema-builder


    【解决方案1】:

    可以看到PHP有Predefined Constants

    PHP_INT_MAX (integer) 此版本支持的最大整数 php。通常是 int(2147483647)。自 PHP 5.0.5 起可用

    【讨论】:

      猜你喜欢
      • 2017-07-14
      • 2016-05-29
      • 2014-05-29
      • 1970-01-01
      • 1970-01-01
      • 2011-11-18
      • 2012-08-21
      • 2023-03-30
      • 1970-01-01
      相关资源
      最近更新 更多