473,769 Members | 5,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

database abstraction layer with limit / total rowcount support

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
3 2404
Con
Hi Rainer, you might want to try PEAR DB package.

Good luck,

-Conrad

Jul 17 '05 #2
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2185
by: Ruby Tuesday | last post by:
Which one is better to do dynamic websites using MySQL? Thanks a.. ADODB, http://php.weblogs.com/ADOdb/ b.. Metabase, http://www.phpclasses.org/browse.html/package/20.html c.. PEAR::DB, http://pear.php.net/manual/en/core.db.php d.. PHPLib database wrappers, http://sourceforge.net/projects/phplib
13
2034
by: lawrence | last post by:
A user writes this sentence: "It was the New Urbanist's nightmare of sprawl run amok." They input that and my PHP script hits it with addslashes() and then the sentence gets put in the database. A slash is likely inserted in front of the quote mark in "Urbanist's". Later the user runs a search of the database for "New Urbanist's nightmare".
2
1739
by: David | last post by:
Is there a good DataBase Abstraction layer that will handle the mySql, Sql Server, and MS Access engines? I do not wish to write the same functions with the three different PHP db functions. I see that php_dba is listed as an extension, but I determine which DBs are supported. However, I think that it does not support the ones I need. Thanks
4
2120
by: Luiz Geron | last post by:
Hi all, I'm testing the PDO wrapper to database modules and I'm wondering how few things like this there are around. My problem, actually, is the paramstyle of modules. I want to use kinterbasdb in the same code I use cx_oracle, for example, but paramstyle changes from one to other, than I searched for things like this and found nothing really usefull. The problem with PDO is that it was so dificult to find, since a few people seems to...
27
1975
by: Brett | last post by:
If I want to easily swap the database I'm using, what is the best method for developing that tier in my application? I'll have basically a 4 tier app: 1. presentation 2. business logic 3. data layer containing standard SQL compliant queries 4. any database I'm looking for the most efficient way to design tier 3. I can't use stored
25
2567
by: Colin McKinnon | last post by:
Hi all, There's lots of DB abstraction layers out there, but a quick look around them hasn't turned up anything which seems to met my requirements. Before I go off and write one I thought I'd ask here if anyone knows of such a beast... I want some code where I present an array of data, and the corresponding primary key and let the code work out whether to INSERT or UPDATE it, I also want to be able to present the data from a QBF or...
0
5578
by: narayan2586 | last post by:
Hi all, When ever i am trying to connect my application it's giving below error message: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: ; nested exception is: javax.ejb.EJBException: Connection to pool failed! - com.ibm.websphere.ce.cm.StaleConnectionException: SQL1224N The database manager is not able to accept new requests, has terminated all requests in progress, or has terminated your...
3
3172
by: Joseph Gruber | last post by:
Hi All. I'm a PHP programer moving to ASP.NET for this project I'm working on. The project I'm working on will require that the ASP.NET application support multiple databases (e.g. Oracle, MySQL and MSSQL). I've done some google searching but am not finding an answer to my question. Is there a database abstraction layer for ASP.NET similar to how there is one for PHP? If not any suggestions/articles on writing one?
8
1839
by: Ivan S | last post by:
What are your recommendations for lightweight database abstraction library (Oracle/MySQL)? I prefer OOP. :) Tnx, Ivan.
0
9583
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10039
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.