Yii Framework Forum: Database Naming Conventions? - Yii Framework Forum

Jump to content

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

Database Naming Conventions? Does Yii expect database tables to be named according to convenition? Rate Topic: -----

#1 User is offline   tommytwoeyes 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 08-March 10

Posted 08 March 2010 - 03:01 PM

Just wondering if it does.. I read the page about naming conventions in the Definitive Guide (including the comments), and although there's no mention of table-naming conventions, there would seem to be some form that Yii is expecting.

I say this because when I generated models with yiic, it created model relationships based on the table names.
0

#2 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 08 March 2010 - 03:20 PM

Hi, yes Yii expects convention. Check this.

// Maybe a hint to the AR page should be put into the convention page of the guide to make things more clear.
0

#3 User is online   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 503
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 08 March 2010 - 06:22 PM

A suggestion regarding DB relationships:

As a newbie (with Yii and PHP, not software development) I have gotten confused many times by the minimalistic syntax of the convention. For example, naming a relationship with the same name as the related model except for the case -- e.g. tbl_state (class State) relates to tbl_country (class Country) by relationship (BELONGS_TO) 'country' -- is confusing to me. I don't know whether it's a relationship or an attribute (field) of the table.

I would suggest that the convention be changed so that relations are named explicitly: in the example above, I call the relation 'relToCountry'. By the same token, the reverse relation would be called 'relFromState'. This way the code is more readable to the guy that will end up maintaining it.

Just saying...
José
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