在laravel4中实现全文检索

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在laravel4中实现全文检索相关的知识,希望对你有一定的参考价值。

In this tutorial I will go over implementing Full-Text search in Laravel 4 .
Those who have used Laravel 3 in the past may remember that there used to be support for FULLTEXT indexes. This functionality has been removed in Laravel 4 but can still easily be implemented.
  1. <?php
  2.  
  3. use IlluminateDatabaseMigrationsMigration;
  4. use IlluminateDatabaseSchemaBlueprint;
  5.  
  6. class CreatePostsTable extends Migration {
  7.  
  8. /**
  9. * Run the migrations.
  10. *
  11. * @return void
  12. */
  13. public function up()
  14. {
  15. Schema::create('posts', function(Blueprint $table) {
  16. $table->engine = 'MyISAM'; // means you can't use foreign key constraints
  17. $table->increments('id');
  18. $table->string('title');
  19. $table->text('body');
  20. $table->timestamps();
  21. });
  22.  
  23. DB::statement('ALTER TABLE posts ADD FULLTEXT search(title, body)');
  24. }
  25.  
  26. /**
  27. * Reverse the migrations.
  28. *
  29. * @return void
  30. */
  31. public function down()
  32. {
  33. Schema::table('posts', function($table) {
  34. $table->dropIndex('search');
  35. });
  36. Schema::drop('posts');
  37. }
  38.  
  39. }

以上是关于在laravel4中实现全文检索的主要内容,如果未能解决你的问题,请参考以下文章

在片段中实现对话框时,必须在添加内容之前请求窗口功能

在片段中实现 onClickListener

在多个片段中的片段中实现选项卡

在 Laravel 4 中实现 Remember Me 函数会返回错误

尝试在片段中实现 OnClick 侦听器 [重复]

在 recyclerview 片段中实现上下文操作模式的问题