PHP code example of jdorn / sql-formatter

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

    

jdorn / sql-formatter example snippets



ry = "SELECT count(*),`Column1`,`Testing`, `Testing Three` FROM `Table1`
    WHERE Column1 = 'testing' AND ( (`Column2` = `Column3` OR Column4 >= NOW()) )
    GROUP BY Column1 ORDER BY Column3 DESC LIMIT 5,10";

echo SqlFormatter::format($query);


echo SqlFormatter::format($query, false);


echo SqlFormatter::highlight($query);

echo SqlFormatter::compress($query)


echo SqlFormatter::removeComments($query);


$queries = SqlFormatter::splitQuery($sql);

SELECT Id as temp, DateCreated as Created FROM MyTable;


    SELECT
    
    Id 
    as temp, DateCreated as Created FROM MyTable;