Question

When and why should you even prefix a table when using yii model generator? I have been told to "In my opinion you should only even prefix if you are using more than one database". Is this right? or is they more I need to know

Was it helpful?

Solution

I believe you should be asking when to prefix your tables not when to use a prefix for a table in gii.

The answer for the first questions is: A prefix is a must when you have to put in more applications into 1 database. Some hosting companies will only allow you a number of mysql (or other) databases on your hosting plan, if you want to put 2 applications into 1 database then their table names might conflict so use a prefix to differentiate the 2. Some people prefix their tables, some do not, I believe it is more a matter of choice right now (you used to have to prefix in the past for some good reasons, but not anymore). I might be wrong on this.

The answer to the second questions is use a prefix in gii whenever you have your tables prefixed in the db. This is so you do not have to have a model called tblUser and just have a normal one called User that is based on a table called tblUser. You will not care what the table is named anyway after you create your model.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top