0

Problem:

I used gii to generate database table models. So If I have any change in users table structure, I used gii and all my relations and other methods are removed from class. So I need to make backup of class and regenerate class and bring back other methods and relations.

Possible Solution:

I changed my class into two classes like this for a table 'users':

class Users extends UsersMapper { public function tableName() { return 'users'; } public function rules() { ..... } public function relations() { ..... } } class UsersMapper extends CActiveRecord { public function getAllUsers() { ...... } public function getBlockedUsers() { ...... } } 

Question:

Above method is working for me and I am using only Users class everywhere in my code. Is it valid method or there is any problem with this logic. Is there any other method.

Thanks

1 Answer 1

1

The Giix extension will create a models/Users class and a models/_base/BaseUsers class for your case. The Users class extends the BaseUsers class. Thus only the BaseUsers class needs to be regenerated on changing the database. It also comes with a couple of extra methods that I use quite a lot.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.