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 
         

afterFind function


Goto page 1, 2  Next
 
Post new topic   Reply to topic    Web Design Forums -> PHP programming forum
View previous topic :: View next topic  
Author Message
PaulKolin



Joined: 25 May 2006
Posts: 108
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


froomzer



Joined: 23 May 2006
Posts: 148
B->afterFind is still called
A I mean
But b is last
Set recursive = 0 or -1
  Reply with quote
PaulKolin



Joined: 25 May 2006
Posts: 108
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
froomzer



Joined: 23 May 2006
Posts: 148
The structure is correct
They way it is returned
  Reply with quote
PaulKolin



Joined: 25 May 2006
Posts: 108
I understand the structure, and it makes sense because of the hasMany.
  Reply with quote
froomzer



Joined: 23 May 2006
Posts: 148
What are you trying to do in the afterFind?
  Reply with quote
PaulKolin



Joined: 25 May 2006
Posts: 108
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
froomzer



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



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



Joined: 23 May 2006
Posts: 148
Yes
The core sends it to your methods in a set format
This is consistent across the board
  Reply with quote
Page 1 of 2 Goto page 1, 2  Next
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