index()" 在 Laravel 中是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37350263/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:50:51  来源:igfitidea点击:

What does index()" mean in Laravel?

phplaravelindexinglaravel-5.2

提问by Van Adrian Cabrera

I have this code $table->integer('card_id')->unsigned()->index();in a table that I created using Laravel framework. Just to make sure what does the index()?

$table->integer('card_id')->unsigned()->index();在使用 Laravel 框架创建的表中有此代码。只是为了确定index()?

回答by Amarnasan

It's the way to say to the Laravel Migration to add indices to that column, in order to get faster results when searching through that particular column.

这是对 Laravel Migration 说的向该列添加索引的方式,以便在搜索该特定列时获得更快的结果。

It's a common procedure in DB design when building tables. Just "index" some particular columns if you plan to make searchs in the table using those columns.

建表时,这是数据库设计中的一个常见过程。如果您打算使用这些列在表中进行搜索,只需“索引”一些特定的列。

I just realized you added that "indexing" tag to your question and that the description of that tag answers your question.

我刚刚意识到您在问题中添加了“索引”标签,并且该标签的描述回答了您的问题。