>  기사  >  백엔드 개발  >  使用PDO执行SQL,导致的连接被重置.

使用PDO执行SQL,导致的连接被重置.

WBOY
WBOY원래의
2016-06-23 13:44:271174검색

用PDO连接数据库是没问题的:

$dsn = "mysql:host=localhost;dbname=php_jquery_example";try {	$dbo = new PDO($dsn, 'root', '123');} catch(Exception $e) {	die($e->getMessage());}


预处理和绑定也没问题:
$sth = $dbo->prepare('SELECT event_id, event_title, event_desc    FROM events    WHERE event_id < ?');$sth->bindParam(1, $calories, PDO::PARAM_INT);


问题在执行上:
$sth->execute();

页面直接死掉,提示连接被重置
直接执行也会出现同样的问题:
foreach ($dbo->query('select * from events') as $row) { ...



用原始的方法连接和查询是没问题的.这是PDO执行SQL语句造成的,纠结了两天了.请高手帮帮我啊.....


回复讨论(解决方案)

下面是aparch错误日志打印出的信息:
[error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
PHP Warning:  PHP Startup: Unable to load dynamic library '..\\..\\php-5.2.14-Win32\\ext\\php_mssql.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '..\\..\\php-5.2.14-Win32\\ext\\php_pdo_mssql.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0

帮忙分析.

用pdo的好处是?????

PHP Warning: PHP Startup: Unable to load dynamic library '
不能加载动态库:php_mssql.dll php_pdo_mssql.dll

是不是因为缺少这两个库影响了页面的执行。

PHP Warning: PHP Startup: Unable to load dynamic library '
不能加载动态库:php_mssql.dll php_pdo_mssql.dll

是不是因为缺少这两个库影响了页面的执行。

应该不是,何况还是 sqlserver 的

用pdo的好处是?????

通用,更换数据库系统只需更换 DSN 串
当然 SQL 指令中也要顾及到差异

问题解决没有?

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.