Created
April 16, 2013 14:24
-
-
Save nightsh/5396310 to your computer and use it in GitHub Desktop.
uglify_query - a function to remove unneded spacing out of SQL queries
This file contains 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 | |
/** uglify_query - a function to remove unneded spacing out of SQL queries | |
* | |
* This is a very basic function that can be used both in OOP and non-OOP | |
* environments, transforming an SQL query that was formatted for readibility | |
* into a short, one-liner, single-spaced query that won't produce a nasty log | |
* pollution and line noise. | |
* | |
* @param string $query The pretty formatted query, with tabs, newlines etc. | |
* @return string The query, stripped of all extra spaces, tabs and newlines | |
* | |
*/ | |
function uglify_query( $query ) { | |
return preg_replace('/[ \t]+/', ' ', preg_replace('/[\r\n]+/', " ", $query)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment