YII Primary Key error

Error: Table “user” does not have a primary key.

Solution:
The crud command requires primary key to be defined in your tables. If you are working with legacy tables and can’t specify primary key, you can declare it in primaryKey() method of your model class.

override method primaryKey in protected/models/User.php
[php]
public function primaryKey()
{
return ‘id’;
}

[/php]

Permanent link to this article: https://blog.openshell.in/2012/04/yii-primary-key-error/

Leave a Reply

Your email address will not be published.