Re: DataObject tweak ok with DB and MDB2

From: Date: Tue, 05 Apr 2005 21:57:38 +0000
Subject: Re: DataObject tweak ok with DB and MDB2
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-18529@lists.php.net to get a copy of this message
On Apr 5, 2005 2:35 PM, Dan Rossi <pear@electroteque.org> wrote: > > On 06/04/2005, at 4:07 AM, Justin Patrin wrote: > > >> > > > > I've made some changes to your version. > > * affectedRows is in the MDB2_Driver_Common class (in MDB2.php) and is > > overridden by some of the drivers themselves. There shouldn't be any > > problem calling it directly (except that it may return an error) > > * You left a require_once 'MDB2/DataObject/Generator.php'; in there. I > > assume you mean DB/DataObject/Generator...or is the Generator also > > changed for MDB2? If so, could you post that? > > * I introduced a new _quote() method which does the logic for checking > > the DB type and calling the appropriate method > > * I added a check to make sure that db_driver is set in the options > > before using it (should this be set already somewhere automatically?) > > > > It might be faster to replace the _quote method and the FETCHMOD stuff > > with options which are set in _connect. This way it would set two more > > small vars once per connect and use those instead of adding lots of > > extra ifs in there. > > > > Here's the file: > > http://formbuilder.reversefold.com/DataObject.DB-MDB2.phps > > and a diff vs. the newest CVS version > > http://formbuilder.reversefold.com/DataObject.DB-MDB2.diff > > > > > > Wow you're a genious, great to have some team work ! > > There are two issues, now your have moved the quoting to a _quote > method you are casting a string to both methods, I might have to check > with Luke but I think his quote is already casting as a string ?? If we cast it twice I don't think that's a problem. IMHO it's better to have leff ifs in the code for the different DBs. > > B_DATAOBJECT_STR) { > $settings .= "$kSql = ". $this->_quote((string) ( > ($v & > DB_DATAOBJECT_BOOL) ? (int)(bool)$this->$k : $this->$k > )) . ' > '; > > Also with the $db_options variable, where does it ever colllect the > info from $options ? I moved it to a nested array so might BC break > other ppl ?? Not sure what you're asking here. I've never used db_options, honestly. You're right, though, if it's currently just db_options you shouldn't be changing it to a nested array. > > I have also noticed i missed the modifylimit query in the delete method > hehe, i guess i'll do it and post it bak. You changed my checks for > method_exists to > $GLOBALS['_DB_DATAOBJECT']['CONFIG']['db_driver'] == > 'DB' which is more efficient ? Well...yes, it should be more efficient, and it's also just a better check. It's better for us to if/switch on the option than to check the object to see if it has a method. > > How do I run that diff file, or have you already done it ? can you give > me pointers on how to run a diff in the future ? OSx has a cool program > called file merger but still working out how to use it, eclipse also > has file merging features but is painful to use. > The source file I put up is the full source of my changed version (all of my changes to your code are applied). The diff file is mostly for Alan's benefit so he can see what we changed since his latest CVS version. You can apply patches with the "patch" utility. ;-) It *may* not work, though as my filenames are probably off. I mostly use diffs as a reference anyway. But you would need the CVS version of DB_DataObject, not your altered copy to apply the patch. Better to just grab my source and work from that. -- Justin Patrin

« previous php.pear.general (#18529) next »