猜测是因为用了服务没用sid的原因,没找到解决办法,所以修改代码
PDOException in Connection.php line 295
SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
composer引入的oracle包里
vendor\topthink\think-oracle\src\Connection.php
protected function parseDsn($config)
{
$dsn = 'oci:dbname=';
if (!empty($config['hostname'])) {
// Oracle Instant Client
$dsn .= '//' . $config['hostname'] . ($config['hostport'] ? ':' . $config['hostport'] : '') . '/';
}
$dsn .= $config['database'];
if (!empty($config['charset'])) {
$dsn .= ';charset=' . $config['charset'];
}
return $dsn;
}
修改为
protected function parseDsn($config)
{
$dsn = 'oci:dbname=';
if (!empty($config['hostname'])) {
// Oracle Instant Client
$dsn.='(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = '.$config['hostname'].')(PORT = '.$config['hostport'].'))
(CONNECT_DATA =
(SID = '.$config['database'].')
)
)';
}
if (!empty($config['charset'])) {
$dsn .= ';charset=' . $config['charset'];
}
return $dsn;
}
完美连接