请教一个棘手的问题 YII的PDO连接 有时候出错

大部分的连接是OK的,操作一晚上大概出现两三次服务器500的错误,而且没有错误的信息.服务器环境 win2003 IIS6 PHP5.38 MYSQL5.5 YII1.8

在调试模式下记录了这一错误:

PHP Error

D:\www\root\YiiRoot\framework\db\CDbConnection.php(405)

393 * @since 1.0.4

394 */

395 protected function createPdoInstance()

396 {

397 $pdoClass=$this->pdoClass;

398 if(($pos=strpos($this->connectionString,’:’))!==false)

399 {

400 $driver=strtolower(substr($this->connectionString,0,$pos));

401 if($driver===‘mssql’ || $driver===‘dblib’ || $driver===‘sqlsrv’)

402 $pdoClass=‘CMssqlPdoAdapter’;

403 }

404 return new $pdoClass($this->connectionString,$this->username,

405 $this->password,$this->_attributes);

406 }

407

408 /**

409 * Initializes the open db connection.

410 * This method is invoked right after the db connection is established.

411 * The default implementation is to set the charset for MySQL and PostgreSQL database connections.

412 * @param PDO $pdo the PDO instance

413 */

414 protected function initConnection($pdo)

415 {

416 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

417 if($this->emulatePrepare!==null && constant(‘PDO::ATTR_EMULATE_PREPARES’))

Stack Trace

#0 + D:\www\root\YiiRoot\framework\db\CDbConnection.php(405): PDO->__construct("mysql:host=localhost;dbname=yii_dn", "root", "password", array())

#1 + D:\www\root\YiiRoot\framework\db\CDbConnection.php(356): CDbConnection->createPdoInstance()

请教强哥和各位大神 这个应该从什么方向考虑? 怎么获取到错误的原因?

帮顶 ! 多半是因为连接太频繁 连接数限制(mysql 配置文件)。

开启AR Schema 缓存吧 ,再者考虑使用缓存来减轻服务器压力。 还有win2003下socket可能有个bug(mysql的连接就跟这个bug有关 你google下) 需要配置解决.

等待其他答案… :lol:

嗯 谢谢了…我感觉也应该是MYSQL的问题 正在努力GOOGLE

貌似问题已经解决… 原因在于KB967723补丁