【发布时间】: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.");
}
}
}
我认为不支持该驱动程序,那么我如何找出哪些是支持的?
【问题讨论】: