Здравствуйте, есть класс Accounts который наследуется от ActiveRecord когда в консольной команде пытаюсь сделать следующее
$account = Accounts::findOne(["id" => 1]);
в консоли выводит это:
Exception 'yii\db\Exception' with message 'could not find driver'
in F:\wamp\www\blog\vendor\yiisoft\yii2\db\Connection.php:547
Stack trace:
0 F:\wamp\www\blog\vendor\yiisoft\yii2\db\Connection.php(861): yii\db\Connection->open()
1 F:\wamp\www\blog\vendor\yiisoft\yii2\db\Connection.php(848): yii\db\Connection->getMasterPdo()
2 F:\wamp\www\blog\vendor\yiisoft\yii2\db\Command.php(219): yii\db\Connection->getSlavePdo()
3 F:\wamp\www\blog\vendor\yiisoft\yii2\db\Command.php(894): yii\db\Command->prepare(true)
4 F:\wamp\www\blog\vendor\yiisoft\yii2\db\Command.php(376): yii\db\Command->queryInternal('fetch', NULL)
5 F:\wamp\www\blog\vendor\yiisoft\yii2\db\Query.php(247): yii\db\Command->queryOne()
6 F:\wamp\www\blog\vendor\yiisoft\yii2\db\ActiveQuery.php(290): yii\db\Query->one(NULL)
7 F:\wamp\www\blog\vendor\yiisoft\yii2\db\BaseActiveRecord.php(107): yii\db\ActiveQuery->one()
8 F:\wamp\www\blog\commands\RbacController.php(36): yii\db\BaseActiveRecord::findOne(Array)
9 [internal function]: app\commands\RbacController->actionTest()
10 F:\wamp\www\blog\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
11 F:\wamp\www\blog\vendor\yiisoft\yii2\base\Controller.php(154): yii\base\InlineAction->runWithParams(Array)
12 F:\wamp\www\blog\vendor\yiisoft\yii2\console\Controller.php(119): yii\base\Controller->runAction('test', Array)
13 F:\wamp\www\blog\vendor\yiisoft\yii2\base\Module.php(454): yii\console\Controller->runAction('test', Array)
14 F:\wamp\www\blog\vendor\yiisoft\yii2\console\Application.php(176): yii\base\Module->runAction('rbac/test', Array)
15 F:\wamp\www\blog\vendor\yiisoft\yii2\console\Application.php(143): yii\console\Application->runAction('rbac/test', Array)
16 F:\wamp\www\blog\vendor\yiisoft\yii2\base\Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
17 F:\wamp\www\blog\yii(20): yii\base\Application->run()
18 {main}
Конфиг консоли:
<?php
Yii::setAlias('@tests', dirname(__DIR__) . '/tests/codeception');
$params = require(__DIR__ . '/params.php');
$db = require(__DIR__ . '/db.php');
$config = [
'id' => 'basic-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'app\commands',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'authManager' => [
'class' => 'yii\rbac\PhpManager',
],
'user' => [
'class' => 'yii\web\User',
'enableAutoLogin' => false,
'identityClass' => 'app\models\Accounts',
'enableSession' => false,
],
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
],
'params' => $params,
/*
'controllerMap' => [
'fixture' => [ // Fixture generation command line.
'class' => 'yii\faker\FixtureController',
],
],
*/
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
return $config;