Re: [rfc] Row limit support for Pear DB
| From: | Frank M. Kromann | Date: | Thu, 01 Nov 2001 22:17:32 +0000 |
| Subject: | Re: [rfc] Row limit support for Pear DB | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-2504@lists.php.net to get a copy of this message | ||
Hi Thomas,
I'll implement this on FrontBase. As from Version 3.3 of Frontbase we have support for
select top x,y from table
and
select * from table limit x,y
This gives us compatibility with both Microsft SQL server and MySQL.
- Frank
> Hi,
>
> Definetly we need that and want/need to implement it :). Here are my
> ideas:
>
> ## Proto ##
> // Modify the query and launch it when needed
> (object) DB_"driver"::limitQuery(string $query, int $from, int $to);
> // Simply launch the query
> (object) DB_common::limitQuery(string $query, int $from, int $to);
>
> $from => row to start from
> $to => last row to fetch
>
> // The DB Result interface to the native functions
> // and maintain the internal counter
> (array) DB_result::fetchRowByLimit([int $fetchmode]);
> // Maintains a internal counter of the last fetched row
> (int) DB_result::getRowCounter();
> // For drivers who supports "limit" somehow
> // simple fetch all the rows
> (array) DB_"driver"::fetchRowByLimit($to, $from, $current);
> // For some drivers emulate this feature with fetch row by number
> (array) DB_common::fetchRowByLimit($to, $from, $current);
>
> (Note1: please propose other method names)
> (Note2: sacrificing some speed in normal fetchs, this thing could be
> integrated into the actual methods fetchRow and fetchInto)
>
> ## Usage ##
>
> $res = $dbh->limitQuery($query, 25, 50);
> while ($row = $res->fetchRowByLimit($mode) {
> echo $res->getRowCounter();
> echo '.- ' . $row['name'] . "\n";
> }
>
> Outputs:
>
> 25.- Peter
> 26.- Foo
> ..
> 50.- Bar
>
> ## Planed Support ##
>
> mysql -> altering query
> pgsql -> altering query
> oci8 -> altering query
> ibase -> unsupported
> rest -> emulated with the fetch row by number feature
> (Note: for the last two I'll be glad to hear better ideas)
>
> This feature is limited to SELECT statements
>
>
> Tomas V.V.Cox
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, e-mail: pear-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: pear-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>