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/explain/01j2gcrbsjet9r8rav114vgfsy
$url = Film::where('description', 'like', '%astronaut%')
    ->visualExplain();

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

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

use Tpetry\LaravelMysqlExplain\Facades\MysqlExplain;

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