The new "with" attribute seems to go some way to fixing it, however
the functionality has changed since first included and the tutorials
out there are dated.

If you include a model for your HABTM "with", then query that model.

Sorry for the non-naming convention tables, from older legacy system.
Packs many Cast, Cast many Packs

Model: Pack
var $hasAndBelongsToMany = array(
                'Cast' => array('className' => 'Cast',
                                        'joinTable' => 'brgPackModel',
                                        'foreignKey' => 'PackID',
                                        'associationForeignKey' => 'ModelID',
                                        'with' => 'PacksCast',
                                        'conditions' => '',
                                        'fields' => '',
                                        'order' => '',
                                        'limit' => '',
                                        'offset' => '',
                                        'unique' => '',
                                        'finderQuery' => '',
                                        'deleteQuery' => '',
                                        'insertQuery' => ''),

Model: Cast
var $hasAndBelongsToMany = array(
                'Pack' => array('className' => 'Pack',
                                        'joinTable' => 'brgPackModel',
                                        'foreignKey' => 'ModelID',
                                        'associationForeignKey' => 'PackID',
                                        'with' => 'PacksCast',
                                        'conditions' => '',
                                        'fields' => '',
                                        'order' => '',
                                        'limit' => '',
                                        'offset' => '',
                                        'unique' => '',
                                        'finderQuery' => '',
                                        'deleteQuery' => '',
                                        'insertQuery' => ''),

Model: PacksCast (HABTM)
var $name = 'PacksCast';
var $useTable = 'brgPackModel';
var $belongsTo = array(
                'Pack' => array('className' => 'Pack',
                                                        'foreignKey' => 
'PackID',
                                                        'conditions' => '',
                                                        'fields' => '',
                                                        'order' => '',
                                                        'counterCache' => ''),
                'Cast' => array('className' => 'Cast',
                                                        'foreignKey' => 
'ModelID',
                                                        'conditions' => '',
                                                        'fields' => '',
                                                        'order' => '',
                                                        'counterCache' => ''),
);

Then..... I unbind the Packs from the Cast so we don't get a full
return in there. As recursion 2 was needed.

$this->Pack->Cast->unbindModel(array('hasAndBelongsToMany' =>
array('Pack')));
$this->set('Packs', $this->Pack->PacksCast->findAll($arrWhere, NULL,
array('Pack.PackDate' => 'DESC'), 50, NULL,2));

This creates an UNGODLY amount of queries, with it pulling categories,
sites, and other tables over and over again.

Works, Pretty ugly queries, think raw SQL would be much faster to run.

As for writting CakePHP.... I think that would be better left to those
with an eye on the direction and conventions of the project, those who
should realise this is a feature at the basis of being able to use
CakePHP for DB access. Without full and proper database support, raw
SQL is much faster and easier to use, so what if a few servers might
not like a query here or there. Kind of defeats the purpose of RAD
when takes 10x as long to write a query in Cake as it does in SQL,
then said query runs twice as slow do to being broken into 50 parts
and looping through everything to construct arrays.

-Ben


On Dec 12, 12:44 pm, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
> On Dec 11, 2007 7:46 PM, jon <[EMAIL PROTECTED]> wrote:
>
>
>
> > I know what you mean. I've spent three days to solve a problem that's
> > three lines of regular PHP code and still no solution. Apparently
> > CakePHP 'just works!' so doesn't need documentation. Yeah, well if it
> > works, it's on minimum wage and giving surly customer service! And
> > except for those days when it doesn't show up to work, and didn't
> > think to call in so you've no idea where it's gone...
>
> Instead of putting down all the work that has gone into CakePHP, why
> don't you try and solve the problem yourself?  You have the source
> code, so why can't you fix it and supply a patch.  I mean, if it's
> really so simple, it should be easy to fix.
>
> Right?
>
> I know this will shock a lot of people on this list, but the people
> who contribute to Cake do it FOR NOTHING.  As a result, bugs may tend
> to languish far longer than they would if there was a dedicated core
> of people getting paid to fix it.  I don't know about you, but by the
> time my day job is over I usually only have a few brain cells left to
> devote to thinking about other projects, so I can understand why some
> bugs sit around.
>
> I am in agreement that this bug (which is almost a year old) should be
> looked after.  Only question is, who is going to do it?  Not you, from
> the sounds of it.
>
> Associative data mapping is HARD.  This bug in particular is hard.
> Maybe I'm stupid, but this doesn't look like a non-trivial fix.  It
> requires a firm understanding of how the data mapping works, and there
> are probably under a dozen people who fully understands how it works.
> I am not one of those people, but I do know some of those people.
> Hopefully one of them kept reading this thread after "Am I choosing
> the right framework" and snarky comments about CakePHP not needing
> documentation and giving surly customer service.  I don't remember
> anyone being promised anything.
>
> --
> Chris Hartjes
>
> My motto for 2007:  "Just build it, damnit!"
>
> @TheKeyboard -http://www.littlehart.net/atthekeyboard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to