PHP code example of nilportugues / sql-query-formatter

1. Go to this page and download the library: Download nilportugues/sql-query-formatter 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/ */

    

nilportugues / sql-query-formatter example snippets



use NilPortugues\Sql\QueryFormatter\Formatter;

$query = <<<SQL
SELECT user.user_id, user.username, (SELECT 
role.role_name FROM role WHERE (role.role_id = :v1) 
LIMIT :v2, :v3 ) AS user_role, (SELECT 
role.role_name FROM role WHERE (role.role_id = :v4)
LIMIT :v5, :v6 ) AS role FROM user WHERE (user.user_id = :v7)
SQL;

$formatter = new Formatter();
echo $formatter->format($query);
bash
    php composer.phar install --dev
    bin/phpunit