使用PDO執行SQL,導致的串連被重設.

來源:互聯網
上載者:User
用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 指令中也要顧及到差異

問題解決沒有?

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.