function FindSQLClause($strSQL, $strBeingSought, $strEndKeywords)
{
	//finds and returns the where condition in SQL
	set_time_limit(10);
	//$strBeingSought="where";
	//$strEndKeywords="group having order limit procedure into for";
	$strLcaseSQL=strtolower($strSQL);
	$intSoughtPos=strpos($strLcaseSQL, $strBeingSought);
	
	$strPossibleClause=substr($strSQL, $intSoughtPos + strlen($strBeingSought));
	$intPostEnd=strlen($strPossibleClause);
	//echo $intPostEnd; 
	$intOldPostEnd=-900;
	while($intPostEnd>0  && $intOldPostEnd!=$intPostEnd)
	{
		$intOldPostEnd=$intPostEnd;
		
		$intPostEnd=PosInList($strEndKeywords, $strPossibleClause,  " ",  true, $quotechar="'");
		//echo $intPostEnd . "=poswhere
"; $strPossibleClause=substr($strPossibleClause, 0, $intPostEnd); //echo $strPossibleClause . "=posclaus
"; } //echo $strPossibleClause; return $strPossibleClause; } function IsolateWhereClause($strSQL) { //finds and returns the where condition in SQL set_time_limit(10); $strBeingSought="where"; $strEndKeywords="limit group having order procedure into"; $strLcaseSQL=strtolower($strSQL); $intSoughtPos=strpos($strLcaseSQL, $strBeingSought); $strPossibleWhereClause=substr($strSQL, $intSoughtPos + strlen($strBeingSought)); $intPostEndWhere=strlen($intPostEndWhere); while($intPostEndWhere>-1) { $intPostEndWhere=PosInList($strBeingSought, $strPossibleWhereClause, " ", true, $quotechar="'");
function FindSQLClause($strSQL, $strBeingSought, $strEndKeywords)
{
	//finds and returns the where condition in SQL
	set_time_limit(10);
	//$strBeingSought="where";
	//$strEndKeywords="group having order limit procedure into for";
	$strLcaseSQL=strtolower($strSQL);
	$intSoughtPos=strpos($strLcaseSQL, $strBeingSought);
	
	$strPossibleClause=substr($strSQL, $intSoughtPos + strlen($strBeingSought));
	$intPostEnd=strlen($strPossibleClause);
	//echo $intPostEnd; 
	$intOldPostEnd=-900;
	while($intPostEnd>0  && $intOldPostEnd!=$intPostEnd)
	{
		$intOldPostEnd=$intPostEnd;
		
		$intPostEnd=PosInList($strEndKeywords, $strPossibleClause,  " ",  true, $quotechar="'");
		//echo $intPostEnd . "=poswhere
"; $strPossibleClause=substr($strPossibleClause, 0, $intPostEnd); //echo $strPossibleClause . "=posclaus
"; } //echo $strPossibleClause; return $strPossibleClause; }