消息为"SQLSTATE [](空)(严重性0)"的PDOException [英] PDOException with message 'SQLSTATE[] (null) (severity 0)'

查看:75
本文介绍了消息为"SQLSTATE [](空)(严重性0)"的PDOException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的服务器正在运行php 5.5,并且已安装FreeTDS dblib.

The server I am working on is running php 5.5 and it has FreeTDS dblib installed.

php -v返回;

PHP 5.5.0-dev (cli) (built: Oct 23 2012 15:41:58) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

PHP 5.5.0-dev (cli) (built: Oct 23 2012 15:41:58) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

构建就是这样;

Configure Command => './configure' '--with-apxs2=/usr/bin/apxs2' '--enable-track-vars' '--with-mssql' '--with-png-dir=/usr' '--with-jpeg-dir=/usr' '--with-zlib-dir=/usr' '--enable-ftp' '--with-gd' '--enable-freetype-4bit-antialias-hack' '--with-config-file-path=/etc' '--enable-calendar' '--with-curl' '--with-curlwrappers' '--enable-exif' '--with-mysql' '--with-ldap' '--with-freetype-dir=/usr' '--enable-sockets' '--with-pdo-mysql' '--enable-soap' '--with-mcrypt' '--with-pdo-dblib' '--with-openssl' '--enable-sysvsem' '--enable-shmop' '--enable-pcntl' '--with-xsl'

我只是尝试使用以下内容连接到SQL Server盒;

I am simply trying to connect to an SQL Server box with the following;

<?php $pdo = new PDO ('dblib:host=fqdn,port;dbname=db', 'usr', 'passwd'); ?>

输出如下;

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[] (null) (severity 0)' in /path/to/file.php:17 Stack trace: #0 /path/to/file.php(17): PDO->__construct('dblib:host=fqdn...', 'usr', 'passwd') #1 {main} thrown in /path/to/file.php on line 1

在搜索现有堆栈文章上已经做了很多工作,它们都与自5.2 RC或更早版本的FreeTDS以来的PHP错误修复有关.考虑到该服务器为5.5,并且具有更高版本的FreeTDS,我想知道是否有人对此非常有用的空SQL状态错误消息有答案.

Having done my fair amount of searching the existing stack posts on this, they all relate to bug fixes for PHP since 5.2 RCs, or earlier versions of FreeTDS. Considering this server is 5.5 and with a later version of FreeTDS I wondered if anyone had an answer for this very helpful empty SQL state error message.

有趣的是,遵循指南以确认您的FreeTDS安装会提示无法运行的命令为我.我将尝试重新安装FreeTDS.

Interestingly following the guide to confirming your FreeTDS installation suggests commands which are failing to run for me. I am going to attempt reinstallation of FreeTDS.

推荐答案

因此,似乎是您连接的地方会影响端口形式.

So, it would appear that it is where you are connecting from which impacts the port form.

在基于Windows的服务器上使用PHP时,连接字符串应为;

When using PHP on a Windows based server, the connection string should be;

<?php $pdo = new PDO ('dblib:host=fqdn,port;dbname=db', 'usr', 'passwd'); ?>

在基于Linux的服务器上使用PHP时,连接字符串应为;

When using PHP on a Linux based server, the connection string should be;

<?php $pdo = new PDO ('dblib:host=fqdn:port;dbname=db', 'usr', 'passwd'); ?>

我假设fqdn/端口的差异是基于您的连接情况,而不是FROM情况.

I had assumed the fqdn/port differences were based on your connection TO and not FROM, situation.

尽管如此,这个模块这个系统的错误处理显然并没有被深思熟虑!

Nevertheless, the error handling of this system this module clearly hasn't been given much thought!

这篇关于消息为"SQLSTATE [](空)(严重性0)"的PDOException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆