Created
March 31, 2011 15:12
-
-
Save alganet/896534 to your computer and use it in GitHub Desktop.
Very, very very simple SQL formatter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function formatSql($sql) | |
{ | |
return preg_replace( | |
'/(select|from|(inner|left) 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