Skip to content

Instantly share code, notes, and snippets.

@henriquemoody
Forked from augustohp/sql_formater.php
Created August 7, 2012 00:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save henriquemoody/3279829 to your computer and use it in GitHub Desktop.
Save henriquemoody/3279829 to your computer and use it in GitHub Desktop.
SQL formater for PHP by @alganet
function formatSql($sql) {
return preg_replace(
'/(select|from|(left |right |natural |inner |outer |cross |straight_)*join|where|limit|update |set|insert |values)/i',
"\n$1\n ", str_replace("\n", '', $sql)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment