1) it is precisely i have tried it see my ultra long post with all the
sql queries and result sets that i know containable is not for me.
i am still looking to see if your linkable behavior is what i need.
however, i am quite noob, so i dont know how to use your one_query
even though i have copied it and pasted it in my behavior folder.
I am a 1 month cake user so please be gentle.
Is there a more complete guide to show me how to use it? ideally would
be if you can provide an example using my scenario above.
if it is better than the joins i am doing, then i am definitely going
to use it greatly because i foresee i am going to use a lot of complex
searches.
my schema once again is
User hasOne Merchant (so Merchant belongsTo User with user_id inside
merchants table)
Shop hasMany Merchant (so Merchant belongsTo Shop with shop_id inside
merchants table)
Shop hasMany Domain (so Domain belongsTo Shop with shop_id inside
domains table)
i am trying to get the first datarow that meets conditions for User,
Domain and the datarow must draw data from all 4 models.
Really looking to hear more from you. Your one_query or linkable
behavior sounds like a lot better than the run of the mill answers i
get from the irc channel.
2) though i have some concerns about the maintainence of your
behavior. looks like you do not have many watchers or people raising
issues.
NO offence.
It is just that i have tried out a few plugins thinking that they
would speed up my work. end up i wasted more time getting them to
work.
the only plugin i am using now is MeioUpload it has promised to a
certain extent is the MeioUpload and the owner is actively answering
issues which is many and that there are plenty of watchers. In fact i
reported 3 issues with suggestions to fix 2 of those 3 issues. the
fixes are adopted by MeioUpload owner hence i am quite happy to
continue to use it. So i am now biased towards code that has owner
actively answering issues and many active users.
Once again, i have nothing against your code. i highly appreciate your
suggestion. and i definitely would want to learn more and definitely
use it if i find it superior to using joins.
Already i can see that it looks more promising than Containable based
on the blogpost link you sent.
So do give me a heads up in terms of using it especially since the
blogpost contains information about using Linkable where as your code
is called one_query.
On May 4, 4:31 pm, AD7six <andydawso...@gmail.com> wrote:
> On May 4, 9:45 am, Kei Simone <kimc...@gmail.com> wrote:
>
> > Your statement on the right join i do not quite understand.
>
> > Which find statement are you explaining on?
>
> > Thank you for being enthusiastic to clear my doubts.
>
> Kei - you don't need to reply to each question individually - you can
> reply to many messages in the same reply ;)
>
> bindModel - if you bind a belongsTo or hasOne - is a join. so there is
> no advantage except it's a lot easier to say:
>
> $this->bindModel(array('hasOne' => array('OtherModel' => array(...));
> return $this->find(...);
> than
> return $this->find($type, $arraywithjoins);
>
> but it depends how explicit you want to be.
>
> Regarding "Your statement on right joins"
>
> These are not equivalent:
>
> return $this->find('all', array(
> 'contain'=>array(
> 'Shop' => array('Domain' =>
> array('conditions' => $someconditions)),
> ),
> ));
>
> return $this->find('all', array(
> 'contain'=>array(
> 'Shop' => array('Domain')),
> ),
> 'conditions' => $someconditions
> ));
>
> Let's say
> $this is users and you've got 10k.
> $someconditions = array('Domain.id' => 42)
> you're expecting one result - the user linked via shop to the domain
> 42.
>
> The first query will return you 10k rows, and the domain data will be
> empty/missing for 9,999 rows - because cake builds the data using
> multiple queries and the first query has no conditions.
>
> The second query will return you 1 row - if you explicitly used joins
> or used one of the behaviors I mentioned that means you get what you
> asked for.
>
> If you're still in doubt - try it.
>
> hth,
>
> AD
>
> $this->
>
>
>
>
>
>
>
> > On May 3, 3:55 pm, AD7six <andydawso...@gmail.com> wrote:
>
> > > On May 2, 1:45 pm, Jon Bennett <jmbenn...@gmail.com> wrote:
>
> > > > > i need to use Merchant model to do a find of all 4 related data.
> > > > > notice that Domain is the only one NOT directly related to Merchant.
>
> > > > > i tried this in a method inside Merchant model:
>
> > > > > $this->Behaviors->attach('Containable');
> > > > > $this->User->Behaviors->attach('Containable');
> > > > > $this->Shop->Behaviors->attach('Containable');
> > > > > $this->Shop->Domain->Behaviors->attach('Containable');
>
> > > > > $this->recursive = -1;
> > > > > $this->User->recursive = -1;
> > > > > $this->Shop->recursive = -1;
> > > > > $this->Shop->Domain->recursive = -1;
>
> > > > > return $this->find('first',
> > > > > array(
> > > > > 'contain'=>array(
> > > > > 'User',
> > > > > 'Shop' => array('Domain' ),
>
> > > > > ),
> > > > > 'conditions' => $conditions
> > > > > ));
>
> > > > >http://book.cakephp.org/view/1323/Containablehaserrorsinterms of
> > > > > telling you where to place the conditions. my way is correct as of 1.3
> > > > > Cakephp
>
> > > > return $this->find('first', array(
> > > > // conditions for the main model
> > > > 'conditions'=>array(),
> > > > // contain
> > > > 'contain'=>array(
> > > > 'User'=>array(
> > > > // conditions for the user model
> > > > 'conditions'=>array('User.status'=>1),
> > > > 'Other', 'Models', 'From', 'User'
> > > > ),
> > > > 'Shop'=>array('Domain'),
> > > > )
> > > > ));
>
> > > Using conditions like that is the equivalent of a right join - you're
> > > still going to get every single "main model" row - and just get an
> > > empty array for any row which links to a user with a status that isn't
> > > 1.
>
> > > hth,
>
> > > AD
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers with their CakePHP related questions.
>
> > > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > > To post to this group, send email to cake-php@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment