Re: DB - Query(limit) vs. LimitQuery() in MySQL
| From: | Peter Bowyer | Date: | Sun, 26 Sep 2004 13:20:04 +0000 |
| Subject: | Re: DB - Query(limit) vs. LimitQuery() in MySQL | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14649@lists.php.net to get a copy of this message | ||
Hello Tommy,
At 12:01 27/09/2004, Tommy Ipsen wrote:
I'm using the DB-package in PEAR and was wondering which of the two approaches are most efficient: $res->Query('SELECT * FROM table LIMIT a, b'); $res->LimitQuery('SELECT * FROM table', a, b); The problem is that I'm using the DB package to provide portability and allow me to more easily switch the DBMS if it becomes necessary and I don't know if MySQL's way of using LIMIT is "industry-standard"?It's industry-standard if you're using MySQL but the whole reason DB provides a limitQuery method is because the syntax isn't standard.
Does LimitQuery take advantage of MySQLs features when executing the query?Yes, as does the PostgreSQL driver. Some of the others emulate this.
To sum all of the above up: Which one should I use and what are the pros and cons of the methods?Use limitQuery if you care about portability. It's designed for this task. If you want pure speed then using query() and writing the limit SQL will be fractionally faster, but in that case why not forget using PEAR::DB and use the native mysql functions instead? Regards, Peter -- Maple Design - quality web design and programming http://www.mapledesign.co.uk