当你看到这个时:
$table->string('email');
字符串到底是什么意思?是 varchar 还是tinytext?
默认值是多长?
我可以在源文件中的哪个位置覆盖该值,而不使用
$table->string('email', 100);
一直吗?
最佳答案
它是varchar,默认长度是255 - 正如源代码中定义的:
public function string($column, $length = 255)
Where in the source files can I override the value
您不应修改源代码。如果这样做,每次运行 Composer update 时都会有被覆盖的风险。每次在代码中定义新字符串时,您应该只定义您喜欢的任何自定义最大值。
尽管我建议您,除非您有充分的理由,否则使用 255 通常是可以的。
关于php - 创建表时默认 Laravel 4 "string"有多长以及如何覆盖默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24775124/