Instead of having a model for each of my tables I would like to have one model for all tables and to be able to switch between tableName according to a GET parameter. What would be the best way to do that and how to do it in a way that Yii first validates the GET parameter.
Example:
A request with ?id=someparam => logic should load table Param.
?id=someparam2 => logic should load table Param2
I guess I can try doing it with if…else… but if someone knows a better way please share
I guess this is not a viable option. I should rather have a model for each table and then create a logic in one controller to switch between models to select tables…as my tables have different metadata.
A model represents a table in a database. But if your models have something common, then create a child of CModel (or CActiveRecord) with all common properties and methods, and then use this model as a parent for your models.