redho home | products | services
Web Design Forums

Web Design Forums  


Web Hosting, Web Design, Software and Web Development Forums  
 FAQFAQ   MemberlistArchive  Log inLog in   RegisterRegister 
         

unknown bug



 
Post new topic   Reply to topic    Web Design Forums -> PHP programming forum
View previous topic :: View next topic  
Author Message
Klimapol



Joined: 27 May 2006
Posts: 134
I'm finally sure that I've nailed down my problem, and I think I mean it this time. I'm not going to call it a bug just yet, more of a
Inconsistancy. I have 2 models, say A hasMany B and B has a afterFind() in the model class. When doing a a->read() it ends up calling the
B->afterFind() when getting the data. The inconsistancy is that when b->read() is called the structure of $results passed into the function is
$results['name']['field']='value' but when b::afterFind() is called from a->read() the structure of $results is $results['name'][0]['field'] = 'value' .
Because of the hasMany the structure of the data makes sense, but I'm curious if you intended the afterFind() to have to cope with receiving differently
Formatted structures from associations.
  Reply with quote


Poolkop



Joined: 01 Jun 2006
Posts: 123
B->afterFind is still called
A I mean
But b is last
Set recursive = 0 or -1
  Reply with quote
Klimapol



Joined: 27 May 2006
Posts: 134
Right, but the $results has an extra dimention and the handling logic needs to be different to handle it if coming from an association,
It seems undesireable to have to code that logic into the afterFind to me, and I wanted your point of view. am I clear in explaining what data I'm seeing?
When b->read() is called the structure of $results passed into the function is $results['name']['field']='value' but when b::afterFind() is called from a->read() the structure of $results is $results['name'][0]['field'] = 'value' .
So my foreach($results is breaking on the association because it has the extra dimention.
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
The structure is correct
They way it is returned
  Reply with quote
Klimapol



Joined: 27 May 2006
Posts: 134
I understand the structure, and it makes sense because of the hasMany.
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
What are you trying to do in the afterFind?
  Reply with quote
Klimapol



Joined: 27 May 2006
Posts: 134
The problem is when $results is a 3? dimention array, from the association, and a 2 dimention array from the model itself.
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
You need to take that into account with your code Klimapol
Like I said, set recursive to 0 or -1 so the hasMany are not returned
  Reply with quote
Klimapol



Joined: 27 May 2006
Posts: 134
Right, I was jsut typing, if it was your opinion of people should have to do so.
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
Yes
The core sends it to your methods in a set format
This is consistent across the board
  Reply with quote
Klimapol



Joined: 27 May 2006
Posts: 134
Ok, that is fine, I just wanted to help bring it to your attention if it was not supposed to be that way. it is kind of dificult to track down, when creating a afterFind() function I would not expect that it would get different data structures. but like I said, the hasmany structure made perfect sense, just handling it seems out of place compared to the rest of cake.
Thank you for your time. and hopefully that is my last major question for a while.
  Reply with quote


Page 1 of 1
Post new topic   Reply to topic    Web Design Forums -> PHP programming forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group