0

Some of our model files have become very large, and I am tasked to split up functionality into separate modules.

I am not sure if it possible to use multiple model classes which are declared in different Modules for the same table?

I have tried using different classes in different modules and it seems to work, aside from being careful which model class i have to call, however I am not sure if this is a good practice, or will there be any complications i need to worry about.

The documentation is little vague in this regard

My current model is declared in protected/models/MyModel.php

I wish to split this into

protected/modules/Moduel1/models/MyModel.phpand protected/modules/Moduel2/models/MyModel.php

EDIT: Clarified the question with more details.

Manquer
  • 7,390
  • 8
  • 42
  • 69
  • What is vague is your question. :) You should show what you have tried and what problem you have. – Michael Härtl Aug 02 '13 at 08:14
  • @MichaelHärtl, lol , i thgt it was a simple enough question, i noe i can access tables using multiple model classes, i just wanted to know if it was good practice to do so, or will there be any problems – Manquer Aug 02 '13 at 08:39
  • It is possible, you can use several models to access same table and can use in different modules, also you can Use custom models, do whatever you want in this custom model class, use it, or just put all your functions of model in one separate file and call them from model. – Coder anonymous Aug 02 '13 at 09:39
  • It's a pretty bad idea conceptually. Among other things, you will now need to know which module's model contains the functions you're trying to use, and you'll need some manual work to map one model to another. Also, test fixtures mapping tables to models will not work. – DCoder Aug 02 '13 at 09:41
  • @DCoder Thats what i thgt.. conceptually it felt wrong, however Each of those functions are only called within the module itself, Thanks for heads up regarding text fixtures, I wanted to consider this because i can truly modularize the application and reuse the module quite easily – Manquer Aug 02 '13 at 10:49
  • @Coderanonymous Thanks for that idea, I can perhaps try and maintain the functions separately and call them from the model – Manquer Aug 02 '13 at 10:51

0 Answers0