Home » Database » DB_DataObject » Bug #7467
Emulated limit support
Details
| Submitted | 2006-04-24 04:48 UTC |
|---|---|
| From | ahayes at wcg dot net dot au |
| Status | No Feedback |
| Package | DB_DataObject |
| PHP Version | 5.1.2 |
| OS | Fedora Core 5 |
| Roadmaps | (Not assigned) |
Comments
[2006-04-24 04:48 UTC] ahayes at wcg dot net dot au
Description:
------------
I have been trying to get (emulated) limiting to work for mssql driver with DB DataObjects, and I (believe I) have worked out where the problem lies (if indeed there is one, which there appeared to be).
As you are probably aware DB_common contains the method limitQuery which allows for emulated limiting for databases that support it, as it sets the properties limit_from and limit_count with $result->setOption (line 1199 DB/common.php).
So, for databases that use emulated limiting we should call this instead of just calling $DB->query.
There are two parts in the DB_DataObjects class that must be modified.
DB_DataObject::_query - Line 2323
=======8<========
if ($_DB_driver == 'DB') {
$result = $DB->query($string);
}
=======>8========
to be changed to:
=======8<========
if ($_DB_driver == 'DB') {
if($DB->features['limit'] === 'emulate' && !empty($this->_query['limit_count'])) {
$result = $DB->limitQuery($string, $this->_query['limit_start'], $this->_query['limit_count']);
} else {
$result = $DB->query($string);
}
=======>8========
And, another part that must be changed so that the number of rows returned is correct is as follows:
DB_DataObject::count - Line 1490
=======8<========
$t = clone($this);
=======>8========
to be changed to:
=======8<========
$t = clone($this);
unset($t->_query['limit_start']);
unset($t->_query['limit_count']);
=======>8========
I believe this is necessary because otherwise the limiting is applied because of the test that occurs to check for emulated limiting (in the first fix). So, there may be a better way to do this.
Note, I have only tested this using mssql and mysql.
Test script:
---------------
N/A
Expected result:
----------------
N/A
Actual result:
--------------
N/A
[2006-06-02 03:22 UTC] ahayes at wcg dot net dot au
So, does that mean the problem is fixed?
Because it did not used to work, and if you are stating that it did (which is what think you are saying) then I think you are incorrect.