Wednesday, November 5, 2008

Undesired Recursion in Models

Hi. I've scoured the web to my best extent without wasting away days
of time on this, and I'm stuck... I'm running a CakePHP site with RC3,
and am having some serious memory overhead issues. As I came into this
project picking up the pieces of another programmer, I've recently
decided it'd be best to restructure the architecture of the model
relationships, as that seemed to be the major problem.

I have what could be best understood as three models. We'll call them
Site, Post, and Datavalues. The problem comes into play when I look at
the variable $this in the app_controller function. When I dump that
variable using the debug() method, I'm presented with about 3000 lines
of data, among which some of the code references indices of an array
inside a Model storing a sub-array of a Parent model, this of course
being prefixed by a line indicating * RECURSIVE.

I have a separate CakePHP site running with different models, and on
that site everything checks out with my model architecture. I realize
that I've left this problem contextually generalized, but there's no
sense in writing a novel if no one has any thoughts or interest in
this issue. Additionally, I thought that this problem might be known
well enough already that, upon reading this article, someone might be
able to offer a suggestion.

As such, is anyone familiar with issues involving recursive model
architecture in CakePHP? Thanks for any feedback you may have to
offer.

The Site model is set up with the assignment:
var $hasMany = array(
'Post' =>
array('className' => 'Post',
'foreignKey' => 'site_id',
)
);


The Post model is set up with the assignment:
var $hasMany = array(
'Datavalue' =>
array('className' => 'Datavalue',
'foreignKey' => 'post_id',
)
);

And lastly, the Datavalue model is set up as follows:
var $belongsTo = array(
'Post' =>
array('className' => 'Post',
'foreignKey' => 'post_id',
)
);

--~--~---------~--~----~------------~-------~--~----~
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: