Class: SqlFormatter
Namespace: utils
Description
SQL Formatter is a collection of utilities for debugging SQL queries. It includes methods for formatting, syntax highlighting, removing comments, etc.
@author Jeremy Dorn jeremy@jeremydorn.com
@author Florin Patan florinpatan@gmail.com
@copyright 2013 Jeremy Dorn
@license http://opensource.org/licenses/MIT
@see http://github.com/jdorn/sql-formatter
@version 1.2.18
Methods
Get stats about the token cache.
@return array An array containing the keys 'hits', 'misses', 'entries', and 'size' in bytes
public static function getCacheStats()
Format the whitespace in a SQL string to make it easier to read.
@param string $string The SQL string
@param bool $highlight If true, syntax highlighting will also be performed
@return string The SQL string with HTML styles and formatting wrapped in a tag
public static function format($string, $highlight = true)
Parameters:
$string$highlight- Default:true
Add syntax highlighting to a SQL string.
@param string $string The SQL string
@return string The SQL string with HTML styles applied
public static function highlight($string)
Parameters:
$string
Split a SQL string into multiple queries. Uses ";" as a query delimiter.
@param string $string The SQL string
@return array An array of individual query strings without trailing semicolons
public static function splitQuery($string)
Parameters:
$string
Remove all comments from a SQL string.
@param string $string The SQL string
@return string The SQL string without comments
public static function removeComments($string)
Parameters:
$string
Compress a query by collapsing white space and removing comments.
@param string $string The SQL string
@return string The SQL string without comments
public static function compress($string)
Parameters:
$string