Skip to content

Instantly share code, notes, and snippets.

@jacksonfdam
Created July 26, 2013 17:47
Show Gist options
  • Select an option

  • Save jacksonfdam/6090792 to your computer and use it in GitHub Desktop.

Select an option

Save jacksonfdam/6090792 to your computer and use it in GitHub Desktop.
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