Php 连接到live oracle DB DSN的本地XAMPP安装
我在PC上本地使用Yii2,但希望连接到我们的生产服务器DB,我尝试了以下字符串:Php 连接到live oracle DB DSN的本地XAMPP安装,php,oracle11g,yii2,Php,Oracle11g,Yii2,我在PC上本地使用Yii2,但希望连接到我们的生产服务器DB,我尝试了以下字符串: 'dbname=//host:port/servicename',但它说连接不支持读取架构 我以前从未尝试将Yii2连接到oracle或连接到live DB。如果可能的话,实现这一目标的方法是什么 我也读了这个链接 并将我的格式更改为 'db' => [ 'class' => '\yii\db\Connection', 'dsn' => 'oci:dbname=SOME_IP_ADD
'dbname=//host:port/servicename',
但它说连接不支持读取架构
我以前从未尝试将Yii2连接到oracle或连接到live DB。如果可能的话,实现这一目标的方法是什么
我也读了这个链接
并将我的格式更改为
'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.");
}
}
}
我想这个驱动程序不受支持,那么我如何确定哪些是呢?您需要安装并启用对Oracle数据库的PHP支持
有一个详细的教程。在搜索了我的设置之后。以下几点对我有用 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\u oci8\u 11g.dll;与Oracle 11gR2即时客户端一起使用
我还必须从PECL下载OCI8DLL驱动程序
我的XAMPP附带了12c,但无法与我的设置配合使用。它已安装并启用。我刚刚从一个手动(无框架)脚本连接到数据库,并重试了数据。但我无法通过Yii2连接