I'm not really familiar with frameworks and MVC paradigm. However I'm considering to start using them. And Yii seems to be quite a good choice.
And here is the problem.
I don't like the idea of multiple models in my project. I want them to "appear" dynamicly depending on my DB structure. I came up with an idea of single model scheme. Let's call this model "Node". Although we have only one model there are still many tables in DB representing all the entities in project.
Now when a Node is created (constructed) it identifies itself (no matter how) as a specific entity and drags all the properties from corresponding table. To do this I'm going to override Node's tableName() method so that it will return correct table name depending on Node's nature. Also I will have to override Node's constructor to prepare Node properly.
I already understand that such Node object will probavly lack rules() and relations(). Though it's still possible to mimic them from DB.
And now the questions: what am I missing? does it comply with MVC philosophy? does it comply with Yii philosophy? am I reinventing some wheel?
I think you'll shoot yourself in the foot at a later point when you'll realize that you need some custom logic in places like before/afterValidate(), etc.
And no, this logic, as well as rules(), safeAttributes() etc, should not be contained in your database (you'd be going to use the COMMENT I guess).
Trust me, you may get a "single-model" by using relatively clean code, but that code won't be future-proof.
Trust me, you may get a "single-model" by using relatively clean code, but that code won't be future-proof.
I realize that this scheme has some additional limitations. But main point is to make some all-purpose platform. You can call it a framework over a framework. I want to be able to support one source tree that is used by different web sites.
I don't think CActiveRecord is appropriate to implement your idea. You may need to duplicate most logic in CActiveRecord in order to support your single-model idea. Also, I think you will face extreme difficulty when dealing with relational queries. Even if you manage to implement your idea, I suspect it will be easily understood by others if you intend to release it in terms of a framework.