Its returning an array object… I have to refine my search and then the results need to be processed. Then the processed result is returned through an array…
Please take a notice of a typo here. You should use
$imr->imrDetails;
or
$imr->getImrDetails();
to get virtual attribute value.
As for your initial question - your function definition and call looks quite normal to me. Seems like there’s a typo in your code which is not visible to us.
That was really help full. Thanks everyone. I found one more thing, that I want to share with everyone. Its much easier and flexible as well if we create a component file there and inside it put our code.
But one thing I would like to ask you guys, will it be okay if we add some functions to the models? Will it affect the whole traditional coding structure in Yii?
Do you mean methods?Model is just a class, with its specific intention, so why not to add a method to this class if this method relevant to the model’s intention?
Thus yes, you can and should add methods to any of your classes if it is a correct place for this definite method: follows MVC structure in our case, follows whole application design, improves the code.
If you mean functions - Yii is OOP framework, so using functions isn’t the best choice from design point of view.