【问题标题】:How can i quickly search a specific id and get all rows of that id in a large database in Laravel with mysql?如何使用 mysql 在 Laravel 的大型数据库中快速搜索特定 ID 并获取该 ID 的所有行?
【发布时间】:2017-09-13 18:12:50
【问题描述】:

我正在 Laravel 中制作结果发布系统应用程序。我正在 MYSQL 数据库中导入大量学生的结果(如 1000000)。学生可以通过角色号和注册号搜索结果。 我将给出两个输入,整个结果数据库需要搜索并找到学生的结果。我应该如何搜索结果,以便很快找到搜索结果。谢谢

【问题讨论】:

  • 在提供数据之前需要修改数据吗?
  • @aaron0207 不,只是搜索
  • 如果有正确的索引,只需对结果进行分页就会很快
  • @aaron0207 我将给出两个输入,需要搜索整个结果数据库并找到学生的结果

标签: mysql laravel


【解决方案1】:
<div class="btn-group">
    <formclass="forminline" action="{{URL::to('searchEmployie')}}" method="get"> 
        <div class="form-group">  
            <input type="text" name="search" class="form-control" id="search" placeholder="{{ trans('app.search_for_action')}}" value="{{Request::get('search')}}"> 
            <button type="submit" class="btn btn-outline btn-default"><i class="icon fa-search" aria-hidden="true"></i></button>

            @if (Request::get('search') != '')
                <a href="{{URL::to('employie')}}" class="btn btn-outline btn-danger" type="button"><i class="icon fa-remove" aria-hidden="true"></i>
                </a>
            @endif
        </div>
    </form>
</div>

controller

$q = Input::get('search');
$employie = Employie::where('employee_name', 'LIKE', '%' . $q . '%')->paginate(2);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多