本文介绍了无法使用PDO连接到Oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这些代码段,但仍然无法连接到Oracle DB.我相信我做对了所有事情,但是我不知道陷阱在哪里.
I have these snippets but I still cannot connect to my Oracle DB. I believe I did everything right but i don't know where the pitfall is.
try {
$user='weltesadmin'; // Enter your DB User Name.
$pass='weltespass'; // Enter your DB Password.
$dataBaseName='weltes'; // Enter your Database Name.
$dbh = new PDO('OCI:dbname='.$dataBaseName.'charset=UTF-8', $user,$pass);
echo "Connection Successful";
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . " ";
die();
}
在php.ini
上:
extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pdo_sqlite_external.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
推荐答案
检查已安装的驱动程序,并查看是否已安装oci
:
Check your installed drivers and see if oci
is installed:
foreach(PDO::getAvailableDrivers() as $driver)
echo $driver, '\n';
如果未显示oci
,则需要安装它( http ://php.net/manual/en/ref.pdo-oci.php )
If oci
don't shown, then need to install it (http://php.net/manual/en/ref.pdo-oci.php)
这篇关于无法使用PDO连接到Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!