I wrote my own, little admin script in Yii. Made and tested on localhost, works fine.
Now, when I've transferred my files to a hosting environment, I get errors like:
'The table `News` for active record class `News` cannot be found in the database.'
It happens, because Yii is looking for 'News' table, while in the database there is only a lower-cased news
one.
I think there are some settings in MySQL that makes my db tables case sensitive or something. Anyway I can't change these settings, as I don't own the server.
Yii inherits table name from class name, is there any way to change it? Like assing some new table name to some variable? Couldn't find the solution.
Thanks
You should keep your table name as lower case. Because in Windows the case sensitive of table never change. Once you put the script in Linux it 'll change all to lower case.. every hosting might be a Linux server ... So keep it in mind.
Your table names should all be lower case, since as said, Unix and Windows behave differently. But there is a method in all your models tableName()
. Here you can specify the table name the model should use:
public function tableName()
{
return 'news';
}