在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.
<?php use IlluminateDatabaseMigrationsMigration; use IlluminateDatabaseSchemaBlueprint; class CreatePostsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('posts', function(Blueprint $table) { $table->engine = 'MyISAM'; // means you can't use foreign key constraints $table->increments('id'); $table->string('title'); $table->text('body'); $table->timestamps(); }); DB::statement('ALTER TABLE posts ADD FULLTEXT search(title, body)'); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('posts', function($table) { $table->dropIndex('search'); }); Schema::drop('posts'); } }
以上是关于在laravel4中实现全文检索的主要内容,如果未能解决你的问题,请参考以下文章