DataObject tweak ok with DB and MDB2
| From: | Dan Rossi | Date: | Tue, 05 Apr 2005 06:35:18 +0000 |
| Subject: | DataObject tweak ok with DB and MDB2 | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-18522@lists.php.net to get a copy of this message | ||
Hi there, I want some ok especially from Alan on this, I tried using the pear db wrapper for MDB2 but sounds crazy and also didnt work entirely. This tweak makes changes to the following methods
_connect
find
fetch
fetchRow
update
insert
joinAdd
There is two method differences between DB and MDB2. These are
quoteSmart -> quote
modifyLimiteQuery -> setLimit
the fetchmode constants in fetchRow in methods fetch and fetchRow.
There was one more issue which was affectedRows and i am trying to work out an equiv for MDB2. I have also updated my MDB2 to beta3 with the BC breaks and no issues so far, I run PHP5 though.
I have tweaked the code to allow to use either DB or MDB2 by checking for methods. I also noticed $db_options from the pear static method wasnt doing anything, so i am sending $db_options to the MDB2 class from a nested array called MDB2 within the DataObject array. Maybe there is a better way by using a factory loader method, but I am not very up to scratch on this way, this tweak is maybe not so efficient, but this is a huge class, there is a tonne of if statements so i doubt this will slow it down anymore.
Let me know if what I have done is helpful, as it became a pain to have to rediff painfully each update having different class and constrant names, i have left the classname and constants as is, so its still DB_DataObject but it allows MDB2 to be used ;)
www.electroteque.org/pear/DataObject.phps