Download the PHP package shipmonk/doctrine-mysql-index-hints without Composer
On this page you can find all versions of the php package shipmonk/doctrine-mysql-index-hints. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shipmonk/doctrine-mysql-index-hints
More information about shipmonk/doctrine-mysql-index-hints
Files in shipmonk/doctrine-mysql-index-hints
Package doctrine-mysql-index-hints
Short Description Custom SQL walker for Doctrine allowing usage of MySQL index hints without need of native queries
License MIT
Informations about the package doctrine-mysql-index-hints
MySQL index hints for Doctrine
This library provides a simple way to incorporate MySQL's index hints into SELECT queries written in Doctrine Query Language via custom SqlWalker. No need for native queries anymore.
Installation:
Simple usage:
Which produces following SQL:
See the used entity (it makes sense to put table names and index names into public constants to bind it together and reference it easily):
Combining multiple hints:
You might need to give MySQL a list of possible indexes or hint it not to use some indices. As you can see, hinting joined tables is equally simple.
Produces this SQL:
Hinting table joined multiple times:
You might need to hint only specific join of certain table. Just add which DQL alias specifies it as third argument.
Produces this SQL:
Advanced usage notes
- Subselects are also supported
- It works even for tables that are not present in the DQL, but are present in SQL!
- For example parent table from class table inheritance when selecting children
- Any invalid usage is checked in runtime
- Table name existence is checked, so you just cannot swap
tableName
andindexName
parameters by accident or use non-existing DQL alias - Forgotten hint or invalid arguments are also checked
- Since those checks cannot be caught by any static analysis tool, it is recommended to have a test for every query
- Table name existence is checked, so you just cannot swap
Combining with optimizer hints:
Since 3.0.0, you can combine this library with shipmonk/doctrine-mysql-optimizer-hints:
All versions of doctrine-mysql-index-hints with dependencies
doctrine/orm Version ^3.0.0
shipmonk/doctrine-hint-driven-sql-walker Version ^2.0.0