table inheritance with active record

So I intensively use table inheritance in my projects and I was always wondering if it’s somehow possible to extend the activerecord baseclass.

For example:

As you can see vehicle is the base class here. What would be the best practice when it comes to setting up the activerecord models for (e.g.) the car table? At the moment I setup all other tables like any other through gii, with the exception adding inverseof() to the vehicle relation.

But would it be possible to extend the vehicle model with the car one?

Would it be possible to extend ActiveRecord: Yes.


class Vehicle extends ActiveRecord {}


class Car extends Vehicle {}

However, I think that would mean that the Car Table would have to have all of the fields in Vehicle PLUS the ones added for Car. Otherwise you would have to get really deep into how Yii loads table info and do a lot of overwriting.

It seems to me that standard ActiveRecord relations would be easier. Using ->with() or ->joinWith() in your queries for eager-loading to cut down SQL calls.

OR am I completely wrong about your question? ;D