gpt4 book ai didi

php - 未找到 pdo 扩展

转载 作者:行者123 更新时间:2023-11-29 18:24:05 26 4
gpt4 key购买 nike

我在我的

中遇到 捕获异常:找不到驱动程序
function connect_to_server()
{
$serverName = DB_HOST;
$this->_connection = new PDO("odbc:Driver={SQL Server};Server=$serverName,1433; Database=".DB_NAME.";",DB_USER,DB_PASS);
// $this->_connection = new PDO("sqlsrv:Server=192.168.1.97;Server=$serverName,1433; Database=".DB_NAME.";",DB_USER,DB_PASS);

if(!$this->_connection)
{
die( print_r( sqlsrv_errors(), true));
}
else
{
return $this->_connection;
}
}

当我把它放在里面时 try catch 就像

try {
$this->_con = $this->connect_to_server() . "\n";
} catch (PDOException $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}

所以我想从 here 安装驱动程序当我在命令中运行时,我处于步骤 yum -y install php-pecl-memcache

Error: php71w-common conflicts with php-common-5.4.16-42.el7.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

所以我尝试寻找解决方案并发现 this 所以我运行 yum install php70w-mysqli ,但它返回了相同的错误。

What is the correct way to install these drivers.

我可以在本地运行它,因为我有这些:

extension=php_bz2.dll
extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
;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_pgsql.dll
;extension=php_shmop.dll

但是在我的服务器中,我的 php.ini 中没有这些。

我只有这个

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example, on Windows:
;
; extension=msql.dll
;
; ... or under UNIX:
;
; extension=msql.so
;
; ... or with a path:
;
; extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.

更新

尝试使用yum -y install php_odbc

但是得到了

Loaded plugins: fastestmirror
Repository packages-microsoft-com-prod is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirror.pregi.net
* epel: mirror.pregi.net
* extras: mirror.pregi.net
* updates: mirror.pregi.net
* webtatic: sp.repo.webtatic.com
No package php_odbc available.
Error: Nothing to do

我运行的位置:php -i | grep PDO

我得到:

PDO
PDO support => enabled
PDO drivers => mysql, sqlite
PDO Driver for MySQL => enabled
PDO Driver for SQLite 3.x => enabled

最佳答案

首先,扩展指令 block 在您的环境中不起作用。原因是您的系统找不到扩展文件。在 php.ini 文档中,有一个示例:

For example, on Windows:
extension=msql.dll

under UNIX:
extension=msql.so

这表示 Windows 和 Unix(Linux) 之间的配置差异。在您的系统中,扩展 block 上的 php.ini 应该是这样的:

extension_dir

extesion_file

一句话,

Windows中,扩展文件位于/ext/中,尾部带有dll

Linux 中,扩展文件位于 prefix/lib/php/ 中,尾部为 so

关于php - 未找到 pdo 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46334371/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com