Re: Re: [rfc] Row limit support for Pear DB
| From: | Tomas V.V.Cox | Date: | Wed, 31 Oct 2001 17:16:59 +0000 |
| Subject: | Re: Re: [rfc] Row limit support for Pear DB | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-2488@lists.php.net to get a copy of this message | ||
On Wednesday 31 October 2001 17:03, John Lim wrote:
> Tomas V.V.Cox <cox@idecnet.com> wrote in message
> news:3BDF377D.B496D8BD@idecnet.com...
>
> As 60-70% of PHP programmers use mysql/postgresql, I think that using
>
> limitQuery($selectSql, $limit, $offset)
Finaly i did it this way :-),
limitQuery($query, $from, $count)
$from, the row to start from
$count, the numbers of rows to fetch
> is more natural. Also since only selects are supported, I suggest
> calling it limitSelect().
I don't like too much the name, but i'll change it if more people think
it is more intuitive.
> > Outputs:
> >
> > 25.- Peter
> > 26.- Foo
> > ..
> > 50.- Bar
>
> Personally I'm not keen on this - the first row returned should be 1
> and not 25 in the above example as getRowCounter() just adds
> complexity. Just store the offset and limit in DB_Result and let the
> users read the values from there if they need getRowCounter()
> equivalents.
The first returned number by getRowCounter() is 1 :-) (sorry it's
difficult to think in all things when writing a quick mail without
having coded any line). About its need, my idea of implementing the row
limit support came from the experience with my Pager class, there were
some people requesting me to add something similar and it takes 2
second in implementing.
> Using fetchRow() and fetchInto() is nice in my opinion because a
> smaller API means that people can switch sql without switching fetch
> API's. Also there is no loss in speed if implemented carefully.
The lost isn't significant but is still there. Please guys, take a look
at the DB_result::fetchRowByLimit() function and judge for your self.
This feature is still experimental, there is no problem to change
things.
> > ## Planed Support ##
> >
> > mysql -> altering query
> > pgsql -> altering query
> > oci8 -> altering query
>
> I didn't know Oracle supported this. I am interested
> in this - what's the sql syntax?
Someone kindly posted a url little time ago here with the idea, and a
friend is trying to adapt it to Pear. Stay tunned for the commit in few
minutes :-)
> > ibase -> unsupported
> > rest -> emulated with the fetch row by number feature
> > (Note: for the last two I'll be glad to hear better ideas)
>
> Store data in a disconnected recordset like Cache_DB's and
> emulate using it.
The cache layer is done by other class in Pear. Now the support for
drivers like mssql or ifx is done by them capabilities of fetching rows
by number. So only the cursor may be big but not the data to fetch.
Tomas V.V.Cox