You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im new in yii freamwork, I want to have a independent database for my module, so I create a db config in my module like this:
1-first I create db.php file that return db config
<?php
/**
* Created by PhpStorm.
* User: Rezvania
* Date: 3/10/2018
* Time: 11:31 AM
*/
return[
'class'=>'yii\db\Connection',
'dsn'=>'mysql:host=localhost;dbname=db_entry_mdu',
'username'=>'root',
'password'=>'',
'charset'=>'utf8',
'tablePrefix'=>'tbl_entry_mdu_'
];
2-so i create config file that modify my module configs
`<?php
/**
* Created by PhpStorm.
* User: Rezvania
* Date: 3/10/2018
* Time: 11:30 AM
*/
$db=require __DIR__.'/db.php';
return[
'defaultRoute'=>'entry',
'components'=>[
'db'=>$db,
]
];`
3-finaly I set that in my Module class
`<?php
/**
* Created by PhpStorm.
* User: Rezvania
* Date: 3/10/2018
* Time: 11:26 AM
*/
namespace app\modules\entry;
use yii\base\Module;
use yii;
class EntryModule extends Module
{
public function init()
{
parent::init(); // TODO: Change the autogenerated stub
\Yii::configure($this,require __DIR__.'/config/config.php');
}
}
`
now when I try to use of tables data I get this error:
yii\base\ErrorException: Exception (Invalid Configuration) 'yii\base\InvalidConfigException' with message 'The table does not exist: {{%user}}'
in D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\db\ActiveRecord.php:353
Hello Yii developers :)
Im new in yii freamwork, I want to have a independent database for my module, so I create a db config in my module like this:
1-first I create db.php file that return db config
2-so i create config file that modify my module configs
3-finaly I set that in my Module class
now when I try to use of tables data I get this error:
yii\base\ErrorException: Exception (Invalid Configuration) 'yii\base\InvalidConfigException' with message 'The table does not exist: {{%user}}'
in D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\db\ActiveRecord.php:353
Stack trace:
#0 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\db\ActiveRecord.php(384): yii\db\ActiveRecord::getTableSchema()
#1 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\db\BaseActiveRecord.php(491): yii\db\ActiveRecord->attributes()
#2 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\db\BaseActiveRecord.php(288): yii\db\BaseActiveRecord->hasAttribute('uname')
#3 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\helpers\BaseHtml.php(2189): yii\db\BaseActiveRecord->__get('uname')
#4 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\helpers\BaseHtml.php(1319): yii\helpers\BaseHtml::getAttributeValue(Object(app\modules\entry\models\Entry), 'uname')
#5 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\helpers\BaseHtml.php(1373): yii\helpers\BaseHtml::activeInput('text', Object(app\modules\entry\models\Entry), 'uname', Array)
#6 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\widgets\ActiveField.php(404): yii\helpers\BaseHtml::activeTextInput(Object(app\modules\entry\models\Entry), 'uname', Array)
#7 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\widgets\ActiveField.php(204): yii\widgets\ActiveField->textInput()
#8 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\widgets\ActiveField.php(176): yii\widgets\ActiveField->render()
#9 D:\Xampp\htdocs\basic\modules\entry\views\entry\index.php(15): yii\widgets\ActiveField->__toString()
#10 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\View.php(336): require('D:\Xampp\htdocs...')
#11 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\View.php(254): yii\base\View->renderPhpFile('D:\Xampp\htdocs...', Array)
#12 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\View.php(156): yii\base\View->renderFile('D:\Xampp\htdocs...', Array, Object(app\modules\entry\controllers\EntryController))
#13 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\Controller.php(384): yii\base\View->render('index', Array, Object(app\modules\entry\controllers\EntryController))
#14 D:\Xampp\htdocs\basic\modules\entry\controllers\EntryController.php(33): yii\base\Controller->render('index', Array)
#15 [internal function]: app\modules\entry\controllers\EntryController->actionIndex()
#16 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#17 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#18 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\Module.php(528): yii\base\Controller->runAction('', Array)
#19 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction('entry', Array)
#20 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#21 D:\Xampp\htdocs\basic\web\index.php(12): yii\base\Application->run()
#22 {main} in D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\ErrorHandler.php:317
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleError(256, 'Exception (Inva...', 'D:\Xampp\htdocs...', 317, Array)
#1 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\ErrorHandler.php(317): trigger_error('Exception (Inva...', 256)
#2 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\widgets\ActiveField.php(178): yii\base\ErrorHandler::convertExceptionToError(Object(yii\base\InvalidConfigException))
#3 D:\Xampp\htdocs\basic\modules\entry\views\entry\index.php(15): yii\widgets\ActiveField->__toString()
#4 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\View.php(336): require('D:\Xampp\htdocs...')
#5 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\View.php(254): yii\base\View->renderPhpFile('D:\Xampp\htdocs...', Array)
#6 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\View.php(156): yii\base\View->renderFile('D:\Xampp\htdocs...', Array, Object(app\modules\entry\controllers\EntryController))
#7 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\Controller.php(384): yii\base\View->render('index', Array, Object(app\modules\entry\controllers\EntryController))
#8 D:\Xampp\htdocs\basic\modules\entry\controllers\EntryController.php(33): yii\base\Controller->render('index', Array)
#9 [internal function]: app\modules\entry\controllers\EntryController->actionIndex()
#10 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#11 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#12 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\Module.php(528): yii\base\Controller->runAction('', Array)
#13 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction('entry', Array)
#14 D:\Xampp\htdocs\basic\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#15 D:\Xampp\htdocs\basic\web\index.php(12): yii\base\Application->run()
#16 {main}
The text was updated successfully, but these errors were encountered: