I am new to yii and learing generating the CRUD operation through gii first i create a country table and generate the model and controller and views using gii i am get following error Invalid Configuration – yii\base\InvalidConfigException The table does not exist: {{%country_search}}
Asked
Active
Viewed 5,829 times
0
-
Are you properly connected to your database and is there this table `country_search`? – Bizley Aug 25 '17 at 07:46
-
yes i am sure that connected to database but i have only country table but no country_search table actually i simply follow the rules of http://www.yiiframework.com/doc-2.0/guide-start-gii.html docs kindly suggest – Anil Kumar Sahu Aug 25 '17 at 07:48
-
You need first to create this table in your database and then you can use Gii to generate code for it in Yii. – Bizley Aug 25 '17 at 07:49
-
ok sir solved it thank you – Anil Kumar Sahu Aug 25 '17 at 07:54
2 Answers
3
Add this to CountrySearch class:
/**
* @inheritdoc
*/
public static function tableName()
{
return 'country';
}

temirbek
- 1,415
- 1
- 14
- 27
0
Just adding to temirbek answer:
file models/Country.php
<?php
namespace app\models;
use yii\db\ActiveRecord;
class Country extends ActiveRecord
{
public static function tableName()
{
return 'country';
}
}

Dirar Abu Kteish
- 11
- 2