It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                                7年前关闭。
            
                    
我正在创建这样的PDO对象:

try {
   $dbh = new PDO( "mysql:host=$host;dbname=$db_name" , $user, $passwd );
} catch( PDOException $e ) {
   echo 'Caught exception: ', $e->getMessage(), "\n";
   die();
}


但没有错误,没有异常,PDO对象中没有任何东西:

var_dump( $dbh );


输出:

object(PDO)#5 (0) {
}


用户名/密码和数据库名称均正确。

非常感谢。

最佳答案

这应该是一个有效的PDO对象。尝试使用它进行确认。

是什么使您认为它“构造错误”?

关于php - PDO对象构造不正确,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13122468/

10-12 04:31