Re: DB_DataObject::joinAdd issue

From: Date: Sun, 19 Jan 2003 04:10:16 +0000
Subject: Re: DB_DataObject::joinAdd issue
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3345@lists.php.net to get a copy of this message
Stijn de Reede wrote:
Alan Knowles wrote:
had a quick look at this, you are probably best adding $run->selectAdd('tTrain.id as tTrain_id, tSchedRun.id as tSchedRun_id');
I don't think this will work, as the find() is applied to the train object. I don't recall the selectAdd of the object to be joined is added to to the object joined upon. You might try $train->selectAdd('tTrain.id as tTrain_id, tSchedRun.id as tSchedRun_id'); This should work, but I don't know if this is a nice implementation. Maybe joinAdd() should import the select conditions set in the joined object. Alan, a word from you about this? I can work on it the next couple of days if you like.
yeah, making sure the selections are merged is probably expected behaviour..
I'm using the same sort of thing for my own code, but I don't recall having problems with the 2 'id' columns, I'll look into it...
I think adding anything more to solve these issues, would only complicate the issue.. in terms of needing to read some documentation, just to save a little extra typing.. - and expecting a second programmer to be aware of some special tricks.. - this is becoming very problematic - especially with the Like stuff. The balance between a & b here is weak on the a) side. a) does it make my code easy to read (can somebody else understand what I'm trying todo, without being given the doc's) b) does it save me alot of typing.. $obj->likeAdd('col','%xxxxx%','OR'); or $obj->whereAdd("col LIKE '%xxxxx%','OR'); %obj->col = '%something'; previously we did try stuff like (I think midgard-lite still uses something like this) $obj->_like_col, or $obj->_col_like $obj->col_isLike = true; as well. we could look at doing $obj->colLike('%xxxxx%'); with overload extension, but it makes the code very difficult to follow. If you compare this to the need for $obj->whereAddIn('col',$array); which does a bit more than just add strings together. (eg. it can optionally quote the elements.. ) I suspect that you are only using Like Queries on a limited number of tables, and Just adding a method in those classes to do $obj->nameLike('%xxxx'); is probably more suitable. At the end of the day, you can add many cool tricks into dataobjects, however, one of the reasons for the intermediate layer (Eg. the ability to put an extends inbetween DataObjects and the Data classes) was to enable people to experiment with these types of addititons, and leave the core reasonably (well try anyway) small... Regards Alan
Also, I noticed that addJoin() is still using the addslashes() function, instead of the $__DB->quote() method, I'll apply a patch shortly. Stijn
I'm reluctant to add to much magic behind the scenes here, as doing join is confusing enough without adding to much unexpected behavour.. Regards Alan
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

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