Sunday, June 30, 2013

Re: Model::AfterFind $results format, associations



On Saturday, 29 June 2013 10:49:19 UTC+2, Vanja Dizdarević wrote:
Thank you Andy for taking time to write all that!

I should have made my goal clearer, I agree - "what array formats can be expected in the afterFind callback?"

Of course, I am trying to access only the respective model's data in the model.

After reading your answer and writing up a test for all possible associations, find types and different recursions, this is my conclusion:

### Option 1:
$results = 
    [
        'id' => '1',
        'field1' => 'value1'
        'HasManyAlias' => [0 => [fields/values...], 1 => [fields/values...], etc..],
        'BelongsToAlias' => [ 'id' => 2, ...],
        'hasOne' => [ 'id' => 5, ...]
    ]

Please show some code demonstrating this format being received in afterFind.

AD

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: