Установил расширенный шаблон приложения, создал две базы данных yii2advanced - одну в локальном сервере баз данных MySQl, другую в удаленном MS SQL Server(Microsoft SQL Server 2012 (SP1))
Код: Выделить всё
'components' => [
'db' => [
'class' => '\yii\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;dbname=yii2advanced',
'username' => 'root',
'password' => 'root',
// 'dsn' => 'sqlsrv:Server=...;Database=yii2advanced;MultipleActiveResultSets=false',
// 'username' => 'sa',
// 'password' => 'sa',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
],
],
Код: Выделить всё
yii migrate
В MS SQL Server:
Код: Выделить всё
CREATE TABLE [dbo].[tbl_user](
[id] [int] IDENTITY(1,1) NOT NULL,
[username] [nvarchar](255) NOT NULL,
[auth_key] [nvarchar](32) NOT NULL,
[password_hash] [nvarchar](255) NOT NULL,
[password_reset_token] [nvarchar](255) NULL,
[email] [nvarchar](255) NOT NULL,
[status] [smallint] NOT NULL,
[created_at] [int] NOT NULL,
[updated_at] [int] NOT NULL,
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[password_reset_token] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[email] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Код: Выделить всё
CREATE TABLE `tbl_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`auth_key` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`password_hash` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password_reset_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`status` smallint(6) NOT NULL DEFAULT '10',
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `password_reset_token` (`password_reset_token`)
ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Код: Выделить всё
C:\php-projects\advanced\tests\codeception\bin>yii fixture/load User
Fixtures namespace is:
tests\codeception\common\fixtures
Global fixtures will be used:
1. yii\test\InitDb
Fixtures below will be loaded:
1. User
Be aware that:
Applying leads to purging of certain data in the database!
Load above fixtures? (yes|no) [no]:yes
Fixtures were successfully loaded from namespace:
"tests\codeception\common\fixtures"
1. yii\test\InitDbFixture
2. tests\codeception\common\fixtures\UserFixture
Попытался загрузить данные фикстуры в удаленную таблицу [dbo].[tbl_user]:
Код: Выделить всё
C:\php-projects\advanced\tests\codeception\bin>yii fixture/load User
Fixtures namespace is:
tests\codeception\common\fixtures
Global fixtures will be used:
1. yii\test\InitDb
Fixtures below will be loaded:
1. User
Be aware that:
Applying leads to purging of certain data in the database!
Load above fixtures? (yes|no) [no]:yes
Exception 'yii\base\InvalidParamException' with message 'Table not found: []'
in C:\php-projects\advanced\vendor\yiisoft\yii2\db\mssql\QueryBuilder.php:182
Stack trace:
#0 C:\php-projects\advanced\vendor\yiisoft\yii2\db\Command.php(754): yii\db\mssql\QueryBuilder->checkIntegrity(false, '', '')
#1 C:\php-projects\advanced\vendor\yiisoft\yii2\test\InitDbFixture.php(94): yii\db\Command->checkIntegrity(false, '')
#2 C:\php-projects\advanced\vendor\yiisoft\yii2\test\InitDbFixture.php(76): yii\test\InitDbFixture->checkIntegrity(false)
#3 C:\php-projects\advanced\vendor\yiisoft\yii2\test\FixtureTrait.php(114): yii\test\InitDbFixture->beforeUnload()
#4 C:\php-projects\advanced\vendor\yiisoft\yii2\console\controllers\FixtureController.php(159): yii\console\controllers\FixtureController->unloadFixtures(Array)
#5 [internal function]: yii\console\controllers\FixtureController->actionLoad('User')
#6 C:\php-projects\advanced\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
#7 C:\php-projects\advanced\vendor\yiisoft\yii2\base\Controller.php(154): yii\base\InlineAction->runWithParams(Array)
#8 C:\php-projects\advanced\vendor\yiisoft\yii2\console\Controller.php(119): yii\base\Controller->runAction('load', Array)
#9 C:\php-projects\advanced\vendor\yiisoft\yii2\base\Module.php(454): yii\console\Controller->runAction('load', Array)
#10 C:\php-projects\advanced\vendor\yiisoft\yii2\console\Application.php(176): yii\base\Module->runAction('fixture/load', Array)
#11 C:\php-projects\advanced\vendor\yiisoft\yii2\console\Application.php(143): yii\console\Application->runAction('fixture/load', Array)
#12 C:\php-projects\advanced\vendor\yiisoft\yii2\base\Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#13 C:\php-projects\advanced\tests\codeception\bin\yii(23): yii\base\Application->run()
#14 {main}
Спасибо.
--
С уважением, Алексей.