Location: PHPKode > projects > ADbNewsSender > ADbNewsSender_2.0.4/protected/skeleton/includes/db_defs/postgresql/query.php.inc
<?php
/* 
    Last change in version: 2.0 
#########################################################################################
#    ADbNewsSender 2 									#
#    Copyright (C) 2009  Florian Grannemann (E-mail: hide@address.com)  		#
#    Website: http://adbnewssender.sf.net						#
#											#
#    This program is free software: you can redistribute it and/or modify		#
#    it under the terms of the GNU General Public License as published by		#
#    the Free Software Foundation, either version 3 of the License, or			#
#    any later version.									#
#											#
#    This program is distributed in the hope that it will be useful,			#
#    but WITHOUT ANY WARRANTY; without even the implied warranty of			#
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the			#
#    GNU General Public License for more details.					#
#											#
#    You should have received a copy of the GNU General Public License			#
#    along with this program.  If not, see http://www.gnu.org/licenses/.		#
#########################################################################################
	
*/
/*
	This file provides the function call query()
	
*/
//PostgreSQL does not know the LIMIT OFFSET, START statement, so we have to parse...
if(preg_match("/^[ ]*(select)/i",$querystring) && preg_match("/[ ]limit[ ][ ]*[0-9]*[ ]*[\,][ ]*[0-9]*/i",$querystring))
{
   // $querystring=preg_replace("/;/","",$querystring);
    $parsestring=explode(" ",$querystring);
    
    $i=count($parsestring);
    $foundat=0;
    while($i >=0)
    {
	if(strtolower($parsestring[$i])=="limit")
	{
	    $foundat=$i;
	    break;
	    $i=0;
	}
	$i--;
    }
    $i=$foundat;

    $i=$foundat+1;
    $newstring=$parsestring[$foundat];
    while($i <count ($parsestring))
    {
	$newstring=$newstring." ".preg_replace("/;/","",preg_replace("/,/","",$parsestring[$i]));
	$i++;
    }
 
    $newparsestring=explode(" ",$newstring);
    $Offset="OFFSET ".$newparsestring[1].";";
    
    $Start=$newparsestring[2];
    $newparsestring[1]=$Start;
    $newparsestring[2]=$Offset;
    
   $newstring=implode(" ",$newparsestring);
   // print "<br>$newstring<br>";

    //now deleting rest of $querystring;

     $i=$foundat+1;
    while($i <count ($parsestring))
    {
	$parsestring[$i]="";
	$i++;
    }
    $parsestring[$foundat]=$newstring;
    
    $querystring=implode(" ",$parsestring);
   
}
	$result= @pg_query($this->session,$querystring);
	if($result==false)
	{
	    $result="";
	}
?> 
Return current item: ADbNewsSender