Friday, September 13, 2013

Re: hasMany weirdness

Please ensure that the Players, Seasons and Divisions tables primary key is ID and not like tablename_id.
When done, try again :)
Enjoy, John

On Friday, 13 September 2013 01:58:43 UTC+3, Eric Haskins wrote:
Has anyone else seen where hasMany returns empty arrays's?  Example 

Players
player_id

Seasons
season_id

Divisions
division_id

PlayersToSeasons < ----- hasMany Players, Seasons, Divisions,
id
season_id
player_id
division_id


So many will come back perfect out of 300 players maybe 20 records will be

Array(

     [200] => array(
           [PlayersToSeasons] => array(
                   id => 3
                   season_id => 3
                   .........   
           ),
           [Players] => array(
           ),
           [Divisions] => array(
           )
    )
)

So the parent where the find is called is perfect but the Players array will be blank or the Divisions array will be blank.

I was forced to write individual queries for all the records I needed.  I checked all the foreignkeys were the same type and everything


 

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