The Table "{{Messages}}" For Active Record Class "message" Cannot Be Found In The Database.

I m getting an error message that says

The table "{{messages}}" for active record class "Message" cannot be found in the database.

I have doubly cross checked - sql is running, the database is connected and there is a table named ‘messages’ in the db.

Is there a specific meaning of curly braces around table names like ‘{{tablename}}’?

Do i need to rename the table to add these two braces in each side ?

Any suggestions to correct this ?

thanks a lot ! :)

Take a look

Also you can set table name explicitly, just add

public function tableName()


    return 'messages';


to your model.

thanks that indeed solved the issue for me.

though i still dont have a clue as to why it did :D

Dear Friend

You might have done that after following the BLOG tutorial.

For example, if you have all the tables in database with prefix tbl_.

Then in your configurationfile you have to declare the tablePrefix property.



			'connectionString' => 'mysql:host=localhost;dbname=blog',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => 'yourPassword',

			'charset' => 'utf8',

			'tablePrefix'=>'tbl_',// DECLARING THE PREFIX



Then in your model


public function tableName()


		return '{{post}}';


If you are not attaching any prefix and having a table like post,then

method tableName is declared in the following way.


public function tableName()


		return 'post';



I think it’s because you haven’t followed good practice when naming your db tables.

Yii assumes that you use a singular name, like ‘user’, ‘message’, ‘page’, ‘link’, …

I often see people naming records in plural, but that is not the True Way.

Think about it: what do you call a HAS_MANY relation to Message?

That’s right: ‘messages’.

@seenivasna - no i got this error message while adding an extension on private-messaging.

Going by your explanation, that means a table name in curly braces means - it refers to the prefix declared in the config file.good to know:)

@jacmoe:thanks for that feedback. i see your point… will ensure that with next project, i keep singular database names.

This is my first yii app and as i progress i am getting to know several things that could have been better done… keeping these experiences for the next project. :)