我安装了Yii 2高级模板。CMD中的"yii迁移“命令与默认的MySQL数据库完美地工作,它按预期使用表迁移和用户填充数据库(参见此处解释的步骤3:https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-installation.md)
但是,"yii“并不适用于postgresql数据库。它产生以下错误消息:

出什么事了,或者少了什么?如果我手动创建数据表(已经测试过),Yii 2框架可以读取数据表,但是迁移命令不想工作。
postgresql所需的pdo扩展在php.ini文件中被注释掉。网页requirements.php显示PDO PostgreSQL扩展的“传递”(没有错误或警告)。
我在公共/config/main-local.php中的db连接配置:
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'tablePrefix' => 'tbl_',
'dsn' => 'pgsql:host=localhost;port=5432;dbname=mytestdb',
'username' => 'postgres',
'password' => 'tuparnix',
'charset' => 'utf8',
// see: http://stackoverflow.com/questions/26436024/how-to-set-default-schema-in-yii2
'schemaMap' => [
'pgsql'=> [
'class'=>'yii\db\pgsql\Schema',
'defaultSchema' => 'public' //specify your schema here
],
], // PostgreSQL
],发布于 2015-07-31 02:02:41
命令行php和web服务器php是不同的php。您需要在命令行php.ini中注释您的postgres驱动程序。请在命令行中运行这些命令以获得更多信息(我不确定这些命令的windows版本是什么,请chk)
which php
php -i发布于 2015-08-06 04:35:04
我在Windows中也有同样的问题,但Linux没有。也许,这来自于驱动程序php_pdo_pgsql + libpq.dll。在phpinfo ()、Postgresql 8.3.3 (windows)或9.2.1 (linux)中有哪些版本是不兼容的。从这边看。您在Windows上使用的服务器是什么?(xampp,easyphp,WampServer)和什么版本的php (5.4,5.5,5.6 .)
https://stackoverflow.com/questions/31730649
复制相似问题