Yii Framework Forum: Cactiverecord... Some Relations Have "0" Suffixed? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cactiverecord... Some Relations Have "0" Suffixed? Rate Topic: -----

#1 User is offline   U4EA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 148
  • Joined: 04-November 12

Posted 27 January 2013 - 06:49 AM

Hi folks,

I'm currently in the process of modelling my DB tables and several times when I have gone to enter the "with()" relation between 2 tables, I have noticed that the relation name has a zero suffix onto it. For instance, "product" is showing as "product0" etc.

Can I ask if this is normal and, if so, why this occurs?
0

#2 User is offline   Reza m 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 148
  • Joined: 07-March 12

Posted 27 January 2013 - 07:00 AM

I think you may have a column with product name in your db table
0

#3 User is offline   U4EA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 148
  • Joined: 04-November 12

Posted 27 January 2013 - 07:45 AM

Hi mate,

Yeah, most or all of the relations have the a column of the same name so table "product" contains a column called "product". Ia this bad practice? Would it be better to have table "product" with the column name renamed to "product_name"?
0

#4 User is offline   Reza m 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 148
  • Joined: 07-March 12

Posted 27 January 2013 - 11:16 AM

View PostU4EA, on 27 January 2013 - 07:45 AM, said:

Hi mate,

Yeah, most or all of the relations have the a column of the same name so table "product" contains a column called "product". Ia this bad practice? Would it be better to have table "product" with the column name renamed to "product_name"?


no it's not bad practice but relations name and columns name both behave as model's attributes so they can't have same names for this reason when gii generates relations it add a 0 after your relation name you can change it but remmember to consider this matter
0

#5 User is offline   U4EA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 148
  • Joined: 04-November 12

Posted 27 January 2013 - 11:32 AM

Merc baradaram. Nokaram.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users