Hi, I’m creating a webapp to manage Assurance agencies. When managing people involved in an accident I have Driver, Owner, Assured, Passenger and so on. To manage this I’ve used successfully the single table inheritance method.
Table ‘Person’ (that contains ALL people) is joined to table ‘Type’ (where I save person_id and person_type_id). The problem is when a Person is -for example- a Driver and Assured at the same time (it’s a common case…) and I do something like this:
$people = Person::model()->with('type')->findAll($criteria);
it doesn’t return same number of records returned by SQL.
Of course, if I do the SQL generated by AR it returns correct number of records.
And of course, if in person_id in ‘Type’ table there aren’t duplicated number of records are the same in SQL and in AR too.
Any idea on why? I think it depends on ‘key’ assigned in array returned by AR. I think the key is PK of object. The same objects, the same keys… so it explains different result.