【问题标题】:local XAMPP install connecting to live oracle DB DSN本地 XAMPP 安装连接到 live oracle DB DSN
【发布时间】:2016-02-28 16:29:46
【问题描述】:

我在我的 PC 上本地使用 Yii2,但希望连接到我们的生产服务器数据库,我尝试了以下字符串:

'dbname=//host:port/servicename', 但它说连接不支持读取架构

我之前从未尝试将 Yii2 连接到 oracle 或连接到实时数据库。如果可能的话,有什么方法可以做到这一点?

我也看了这个链接https://www.quora.com/How-do-I-connect-Yii-to-Oracle 并将我的更改为提到的格式

 'db' => [ 
  'class' => '\yii\db\Connection',
  'dsn' => 'oci:dbname=SOME_IP_ADDRESS:PORT/YOUR_SID;charset=UTF8',
  'username' => 'your_username',
  'password' => 'your_password',
  'charset' => 'utf8',
], 

但我遇到了同样的错误。除非我使用服务名称代替 SID

更新

好的,看看 Yii 代码

/**
 * Returns the schema information for the database opened by this connection.
 * @return Schema the schema information for the database opened by this connection.
 * @throws NotSupportedException if there is no support for the current driver type
 */
public function getSchema()
{
    if ($this->_schema !== null) {
        return $this->_schema;
    } else {
        $driver = $this->getDriverName();
        if (isset($this->schemaMap[$driver])) {
            $this->_schema = \Yii::createObject($this->schemaMap[$driver]);
            $this->_schema->db = $this;
            return $this->_schema;
        } else {
            throw new NotSupportedException("Connection does not support reading schema information for '$driver' DBMS.");
        }
    }
}

我认为不支持该驱动程序,那么我如何找出哪些是支持的?

【问题讨论】:

    标签: php oracle11g yii2


    【解决方案1】:

    您需要安装并启用对 Oracle 数据库的 PHP 支持。

    有详细教程here

    【讨论】:

    • 它已安装并启用。我刚刚从手动(无框架)脚本连接到数据库并重试了数据。但我无法通过 Yii2 连接
    【解决方案2】:

    在对我的设置进行了一些搜索之后。以下对我有用

    config/db.php

    return [
    'class' => 'yii\db\Connection',
    'dsn' => 'oci:dbname=IP_ADDRESS:PORT/DB_NAME', 
    'username' => 'USERNAME',
    'password' => 'PASSWORD',
    'charset' => 'utf8',
    ];
    

    我还必须在我的 php.ini 文件中取消注释

    extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client

    我还必须从 PECL http://pecl.php.net/package/oci8/2.0.8/windows/ 下载 OCI8 DLL 驱动程序

    我的 XAMPP 附带 12c,但无法与我的设置配合使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-28
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 2012-02-09
      • 1970-01-01
      • 2010-09-30
      相关资源
      最近更新 更多