PHP code example of tpetry / laravel-mysql-explain

1. Go to this page and download the library: Download tpetry/laravel-mysql-explain library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tpetry / laravel-mysql-explain example snippets


// $url will be e.g. https://mysqlexplain.com/e/C0Omak70mLEXfok1a7Oo1n
$url = Film::where('description', 'like', '%astronaut%')
    ->explainForHumans();

// URL to EXPLAIN will be printed to screen
$users = Film::where('description', 'like', '%astronaut%')
    ->dumpExplainForHumans()
    ->get();

// URL to EXPLAIN will be printed to screen & execution is stopped
$users = Film::where('description', 'like', '%astronaut%')
    ->ddExplainForHumans()
    ->get();

use Tpetry\MysqlExplain\Facades\MysqlExplain;

// $url will be e.g. https://mysqlexplain.com/e/H1pfKQ7FH3HnH87dS64Wk1
$url = MysqlExplain::submitQuery(
    DB::connection('mysql'),
    'SELECT * FROM actor WHERE first_name = ?',
    ['PENEL\'OPE'],
);