A super simple package allowing for use MySQL 'USE INDEX' and 'FORCE INDEX' statements.

Overview

Laravel MySQL Use Index Scope

A super simple package allowing for use MySQL USE INDEX and FORCE INDEX statements.

Requirements

  • PHP ^7.4 | ^8.0
  • Laravel 6, 7 and 8

Installation

composer require vpominchuk/laravel-mysql-use-index-scope

Usage

Simply reference the required trait in your model:

Model:

    use VPominchuk\ModelUseIndex;
    
    class MyModel extends Model
    {
        use ModelUseIndex;
    }

Anywhere in the code:

    $builder = MyModel::where('name', $name)->where('age', $age)->
        useIndex($indexName)->...

Database table structure:

You need to create a named index with required name. For example:

Laravel Migration:

    $table->index(['name', 'age'], 'user_age_index');

Available methods

useIndex($indexName)

Tells MySQL to use an index if it possible.

forceIndex($indexName)

Force MySQL to use an index if it possible.

ignoreIndex($indexName)

Ask MySQL to ignore an index if it possible.

Security

If you discover any security related issues, please use the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
A package to easily make use of Simple Icons in your Laravel Blade views.
A package to easily make use of Simple Icons in your Laravel Blade views.

Blade Simple Icons A package to easily make use of Simple Icons in your Laravel Blade views. For a full list of available icons see the SVG directory.

A simple to use opinionated ERP package to work with Laravel

Laravel ERP A simple to use opinionated ERP package to work with Laravel Installation You can install the package via composer: composer require justs

Public API for the project coding.events. Made in PHP 8.0 with Lumen 8, PHP-FPM, NGINX and MySQL 8.
Public API for the project coding.events. Made in PHP 8.0 with Lumen 8, PHP-FPM, NGINX and MySQL 8.

coding.events API Uma API feita apenas para passar o tempo, montando uma API para o site coding.events. Sinta-se livre para usar esse código como es

An application with Laravel, Vue, Redis and Mysql

p align="center"a href="https://laravel.com" target="_blank"img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%2

🧾 Online test site with the human sciences theme. Using: HTML5, CSS3, Js., PHP7 and MySQL. 🚀
🧾 Online test site with the human sciences theme. Using: HTML5, CSS3, Js., PHP7 and MySQL. 🚀

form-ciencias-humanas 🚀 Technologies Lunacy HTML5 CSS3 PHP7 MYSQL Animate.css Illustrations from icons8: Earth care from Anna Antipina Earth and Moon

PcTools is a proyect developed using {JavaScript,HTML5,CSS} for frontend and {PHP => Mysql} for backend.
PcTools is a proyect developed using {JavaScript,HTML5,CSS} for frontend and {PHP = Mysql} for backend.

PcTools-Proyect PcTools is a proyect developed using {JavaScript,HTML5,CSS} for frontend and {PHP = Mysql} for backend. Future Improvements # Replace

Laravel Mysql Spatial Builder Extension

magutti-spatial V2 Laravel Builder Mysql Spatial Extension Laravel Builder extensions to calculate distances between two Spatial points using Mysql na

For using Laravel with a pre-existing MySQL Database

MySQL to Laravel This is a script to help with mapping an existing MySQL database to a new Laravel build. Place the script in the public folder of you

Software para consultas veiculares construído com PHP, Laravel e MySQL
Software para consultas veiculares construído com PHP, Laravel e MySQL

DespCar Um projeto de uso pessoal para um despachante veícular para consulta de carros através da placa Sobre o Projeto Construído Com PHP PHPUnit Lar

Comments
  • use with DB::

    use with DB::

    Thanks for the great work.

    Is there any way to change this package to work with the DB:: query builder? for example the query below: DB::select("select name from users USE INDEX (names) limit 10");

    being written like: DB::table('users')->select('name')->useIndex('names')->limit(10);

    opened by omidMolaverdi 1
Releases(v1.0.4)
Owner
Vasyl
Software engineer at Haigh Consultancy Services. Photography as a hobby.
Vasyl
Sqlcommenter is a plugin/middleware/wrapper to augment SQL statements from laravel

sqlcommenter is a plugin/middleware/wrapper to augment SQL statements from laravel with comments that can be used later to correlate user code with SQL statements.

Google 7 Jul 14, 2022
A simple job posting application using PHP with an Admin Panel. Register, Login and create the job in apnel. The job gets posted on index page.

Jobee A simple job posting application using PHP with an Admin Panel. Register, Login and create the job in apnel. The job gets posted on index page.

Fahad Makhdoomi 2 Aug 27, 2022
A simple package allowing for consistent API responses throughout your Laravel application

Laravel API Response Helpers A simple package allowing for consistent API responses throughout your Laravel application. Requirements PHP ^7.4 | ^8.0

F9 Web Ltd. 441 Jan 5, 2023
Send ping to search engine by Index now protocol.

Index now PHP protocol Easy to use protocol that websites can call to notify search engines whenever website contents on any URL is updated or created

Baraja packages 3 Sep 10, 2022
An index of Laravel's cascading comments

Cascading Comments An index of Laravel's cascading comments. Visit the site at cascading-comments.sjorso.com. About This is a cascading comment: casca

Sjors Ottjes 4 Apr 28, 2022
PlayZ is an esport event organization and management website allowing the creation of tournaments on the most popular video games of the esport scene.

PlayZ the playz to play Table of Contents Description "What is Playz?" In one sentence PlayZ is "an esport event organization and management website a

Antoine Saunier 2 Dec 7, 2021
Madison is a platform for lawmakers to share legislation with their citizens, allowing the community to add comments and suggest improvements.

Madison Madison is an open-source document engagement and feedback platform. While Madison can be used to collaborate on many different kinds of docum

OpenGov Foundation 591 Dec 17, 2022
A Laravel package that allows you to use multiple ".env" files in a precedent manner. Use ".env" files per domain (multi-tentant)!

Laravel Multi ENVs Use multiple .envs files and have a chain of precedence for the environment variables in these different .envs files. Use the .env

Allyson Silva 48 Dec 29, 2022
A simple to use query builder for the jQuery QueryBuilder plugin for use with Laravel.

QueryBuilderParser Status Label Status Value Build Insights Code Climate Test Coverage QueryBuilderParser is designed mainly to be used inside Laravel

Tim Groeneveld 149 Nov 11, 2022
A Laravel chat package. You can use this package to create a chat/messaging Laravel application.

Chat Create a Chat application for your multiple Models Table of Contents Click to expand Introduction Installation Usage Adding the ability to partic

Tinashe Musonza 931 Dec 24, 2022