Re: Problems with PEAR::DB limitQuery
| From: | Alexey Borzov | Date: | Mon, 08 Dec 2003 14:56:45 +0000 |
| Subject: | Re: Problems with PEAR::DB limitQuery | ||
| References: | 1 2 | Groups: | php.pear.dev php.pear.general |
| Request: | Send a blank email to pear-dev+get-24267@lists.php.net to get a copy of this message | ||
Hi!
Jeroen Houben wrote:
In older versions the LIMIT #, # *was* correct. From the postgresql changelog @ http://developer.postgresql.org/~momjian/HISTORY.html (under migrating to 7.3) : Disable LIMIT #,# syntax; now only LIMIT # OFFSET # supported (Bruce) So the class should do a version check and then execute the proper code. HTH,The class should NOT do any version check, as LIMIT # OFFSET # syntax is valid for all PostgreSQL versions, which is not true for LIMIT #,#. Martin is right.
I found with an aplication I started using the the limitQuery method has problems with PostgreSQL. Basically, in PostgreSQL (don't know hpow others do it) you do a: LIMIT count OFFSET start Where start and count are self explained. So, in DB/pgsql.php, this: // }}} // {{{ modifyLimitQuery() function modifyLimitQuery($query, $from, $count) {$query = $query . " LIMIT $count, $from"; return $query;} Should be changed to this: // }}} // {{{ modifyLimitQuery() function modifyLimitQuery($query, $from, $count) {$query = $query . " LIMIT $count OFFSET $from"; return $query;} Good luck!