By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,208 Members | 1,592 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,208 IT Pros & Developers. It's quick & easy.

database abstraction layer with limit / total rowcount support

P: n/a
hi!

i tested several php database abstraction layers (db, mdb(2), creole,
adodb, etc), but i always missed one really important feature:
i need a method for a limited select which gives me the resultset and
the total number of rows the select would have returned without the
limit.
nativly this is very easy
SELECT SQL_CALC_FOUND ROWS * FROM table LIMIT 0,10 in mysql for
example.

does anybody know an abstraction layer which supports this?

thanks,
rainer
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Con
Hi Rainer, you might want to try PEAR DB package.

Good luck,

-Conrad

Jul 17 '05 #2

P: n/a
Hello,

on 03/28/2005 11:22 AM Rainer Collet said the following:
i tested several php database abstraction layers (db, mdb(2), creole,
adodb, etc), but i always missed one really important feature:
i need a method for a limited select which gives me the resultset and
the total number of rows the select would have returned without the
limit.
nativly this is very easy
SELECT SQL_CALC_FOUND ROWS * FROM table LIMIT 0,10 in mysql for
example.

does anybody know an abstraction layer which supports this?


There seems to be not much point to add such feature to an abstraction
layer when only MySQL supports it and you can implement what you
portably using a simple SELECT count(*) FROM table without the limit clause.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #3

P: n/a
Rainer Collet wrote:
hi!

i tested several php database abstraction layers (db, mdb(2), creole,
adodb, etc), but i always missed one really important feature:
i need a method for a limited select which gives me the resultset and
the total number of rows the select would have returned without the
limit.
nativly this is very easy
SELECT SQL_CALC_FOUND ROWS * FROM table LIMIT 0,10 in mysql for
example.

does anybody know an abstraction layer which supports this?

thanks,
rainer


How hard would it be to hack this in yourself? If you are dealing with an
abstraction layer, it must be constructing the SQL, and so it should be
possible to take a form of the SQL w/o the LIMIT clause and then use
db-specific *_num_rows() function.

This does leave open the whole question of whether or not such things are
good practice in terms of performance, but laying that aside it should be
easy enough to add.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.