cvs: php4 /pear/DB ibase.php

From: Date: Sun, 13 Jan 2002 21:59:43 +0000
Subject: cvs: php4 /pear/DB ibase.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1929@lists.php.net to get a copy of this message
cox Sun Jan 13 16:59:43 2002 EDT Modified files: /php4/pear/DB ibase.php Log: Added modifyLimitQuery(). Only avaible for the Firebird syntax (ibase(firebird)://user:pass@host/db) (contributed by Ludovico Magnocavallo <ludo@sumatrasolutions.com>) Index: php4/pear/DB/ibase.php diff -u php4/pear/DB/ibase.php:1.28 php4/pear/DB/ibase.php:1.29 --- php4/pear/DB/ibase.php:1.28 Thu Dec 27 06:53:19 2001 +++ php4/pear/DB/ibase.php Sun Jan 13 16:59:43 2002 @@ -16,7 +16,7 @@ // | Authors: Sterling Hughes <sterling@php.net> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.28 2001/12/27 11:53:19 cox Exp $ +// $Id: ibase.php,v 1.29 2002/01/13 21:59:43 cox Exp $ // // Database independent query interface definition for PHP's Interbase // extension. @@ -97,6 +97,35 @@ // should return an error code only. return DB::isManip($query) ? DB_OK : $result; } + + // {{{ modifyLimitQuery() + + /** + * This method is used by backends to alter limited queries + * Uses the new FIRST n SKIP n Firebird 1.0 syntax, so it is + * only compatible with Firebird 1.x + * + * @param string $query query to modify + * @param integer $from the row to start to fetching + * @param integer $count the numbers of rows to fetch + * + * @return the new (modified) query + * @author Ludovico Magnocavallo <ludo@sumatrasolutions.com> + * @access private + */ + + function modifyLimitQuery($query, $from, $count) + { + if ($this->dsninfo['dbsyntax'] == 'firebird') { + $from++; // SKIP starts from 1, ie SKIP 1 starts from the first record + $query = preg_replace('/^\s*select\s(.*)$/is', + "SELECT FIRST $count SKIP $from $1", $query); + } + return $query; + } + + // }}} + // {{{ nextResult()

« previous php.pear.cvs (#1929) next »