phemellc / yii2-settings

Yii2 Settings Module
Other
151 stars 74 forks source link

Database Exception after installating #39

Closed waza-ari closed 8 years ago

waza-ari commented 8 years ago

Hi,

I installed version 0.3 via composer and ran the migration scripts. Further, I added the relevant sections to the configuration. However I get the following error when accessing the "/settings" module:

Database Exception – yii\db\Exception
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'judotm.Setting' doesn't exist
The SQL being executed was: SELECT DISTINCT `section` FROM `Setting`

Error Info: Array
(
    [0] => 42S02
    [1] => 1146
    [2] => Table 'judotm.Setting' doesn't exist
)

↵
Caused by: PDOException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'judotm.Setting' doesn't exist

in /var/www/html/hc/vendor/yiisoft/yii2/db/Command.php at line 837

Seems like the module tries to access the Settings-table with capital S. I verified that the table exists, however with a small s.

mysql> use judotm

Database changed
mysql> show tables;
+------------------+
| Tables_in_judotm |
+------------------+
| ...              |
| settings         |
| ...              |
+------------------+
11 rows in set (0,00 sec)

mysql> describe settings;
+----------+--------------+------+-----+---------+----------------+
| Field    | Type         | Null | Key | Default | Extra          |
+----------+--------------+------+-----+---------+----------------+
| id       | int(11)      | NO   | PRI | NULL    | auto_increment |
| type     | varchar(255) | NO   |     | NULL    |                |
| section  | varchar(255) | NO   | MUL | NULL    |                |
| key      | varchar(255) | NO   |     | NULL    |                |
| value    | text         | YES  |     | NULL    |                |
| active   | tinyint(1)   | YES  |     | NULL    |                |
| created  | datetime     | YES  |     | NULL    |                |
| modified | datetime     | YES  |     | NULL    |                |
+----------+--------------+------+-----+---------+----------------+
8 rows in set (0,00 sec)

Stack Trace:

1. in /var/www/html/hc/vendor/yiisoft/yii2/db/Schema.php at line 628
2. in /var/www/html/hc/vendor/yiisoft/yii2/db/Command.php at line 852 – yii\db\Schema::convertException(PDOException, 'SELECT DISTINCT `section` FROM `...')
3. in /var/www/html/hc/vendor/yiisoft/yii2/db/Command.php at line 359 – yii\db\Command::queryInternal('fetchAll', null)
4. in /var/www/html/hc/vendor/yiisoft/yii2/db/Query.php at line 206 – yii\db\Command::queryAll()
5. in /var/www/html/hc/vendor/yiisoft/yii2/db/ActiveQuery.php at line 132 – yii\db\Query::all(null)
6. in /var/www/html/hc/vendor/yii2mod/yii2-settings/views/default/index.php at line 38 – yii\db\ActiveQuery::all()
7. in /var/www/html/hc/vendor/yiisoft/yii2/base/View.php at line 325 – require('/var/www/html/hc/vendor/yii2mod/...')
8. in /var/www/html/hc/vendor/yiisoft/yii2/base/View.php at line 247 – yii\base\View::renderPhpFile('/var/www/html/hc/vendor/yii2mod/...', ['searchModel' => yii2mod\settings\models\search\SettingModelSearch, 'dataProvider' => yii\data\ActiveDataProvider])
9. in /var/www/html/hc/vendor/yiisoft/yii2/base/View.php at line 149 – yii\base\View::renderFile('/var/www/html/hc/vendor/yii2mod/...', ['searchModel' => yii2mod\settings\models\search\SettingModelSearch, 'dataProvider' => yii\data\ActiveDataProvider], yii2mod\settings\controllers\DefaultController)
10. in /var/www/html/hc/vendor/yiisoft/yii2/base/Controller.php at line 371 – yii\base\View::render('index', ['searchModel' => yii2mod\settings\models\search\SettingModelSearch, 'dataProvider' => yii\data\ActiveDataProvider], yii2mod\settings\controllers\DefaultController)
11. in /var/www/html/hc/vendor/yii2mod/yii2-settings/controllers/DefaultController.php at line 61 – yii\base\Controller::render('index', ['searchModel' => yii2mod\settings\models\search\SettingModelSearch, 'dataProvider' => yii\data\ActiveDataProvider])
12. yii2mod\settings\controllers\DefaultController::actionIndex()
13. in /var/www/html/hc/vendor/yiisoft/yii2/base/InlineAction.php at line 55 – call_user_func_array([yii2mod\settings\controllers\DefaultController, 'actionIndex'], [])
14. in /var/www/html/hc/vendor/yiisoft/yii2/base/Controller.php at line 151 – yii\base\InlineAction::runWithParams([])
15. in /var/www/html/hc/vendor/yiisoft/yii2/base/Module.php at line 455 – yii\base\Controller::runAction('', [])
16. in /var/www/html/hc/vendor/yiisoft/yii2/web/Application.php at line 84 – yii\base\Module::runAction('settings', [])
17. in /var/www/html/hc/vendor/yiisoft/yii2/base/Application.php at line 375 – yii\web\Application::handleRequest(yii\web\Request)
18. in /var/www/html/hc/web/index.php at line 12 – yii\base\Application::run()

Any idea what the problem could be? Thanks in advance

arisk commented 8 years ago

Hi, Can you show your configuration? In the model the database table name is set to settings plural and with a lowercase "s". Are you using your own model?

waza-ari commented 8 years ago

Hi,

my configuration is pretty basic, have a look at this snippet. I did not change any of your code, no custom models, just plain installation.

The table name is set to:

public static function tableName()
{
    return '{{%settings}}';
}

It might be worth mentioning that I use PHP7, however this should make no difference...

arisk commented 8 years ago

You're using yii2mod\settings\Module which started as a fork of this project. It was in your stack trace from above but I missed it before. This project is pheme/yii2-settings

waza-ari commented 8 years ago

Doh! You are absolutely right... Had both included in my composer.json, used the migration of this module but the code of the other one... sorry. Deleted the yii2mod module, changed configuration and it works now.

Thanks for your help and sorry for my misunderstanding.

arisk commented 8 years ago

Not a problem. Glad to help :)