Software development - programming solutions

Display a SQL query for debugging in PHP  
function display a T-SQL query in textarea (PHP4, PHP5)
//display an T-SQL Query in textarea (for sql code debugging by example)

function ShowSQLQuery($q, $cols=100, $rows=10)
{

$dataSQL=ltrim($q);

$keySQL=array("select", "from", "where", "left", "inner", "case", "else", "when", "union", "union all","order", "group", " \) as");
foreach($keySQL as $key=>$value)
{
$dataSQL=eregi_replace(" ".$value, chr(13).chr(10).strtoupper($value), $dataSQL);
}

echo '<div style="text-align: center; width: 100%;"><textarea cols="'.$cols.'" rows="'.$rows.'" name="sql_query" id="sql_query">';
echo $dataSQL;
echo '</textarea></div>';
}

eXTReMe Tracker
© 1999 - 2017 (site) © 2010 - 2017 (page) Dan Mihaiu, Europe, Romania
About site statistics   About site   Copyright   Stats   Privacy Policy   Main site