我有以下连接代码:
$this->connectionString = 'mysql:host=' . db_config_DBConfig::$MySQLserverName . ';dbname=' . db_config_DBConfig::$MySQLdbName . ';port=' . db_config_DBConfig::$MySQLport .';connect_timeout=15';
$this->connection = new PDO($this->connectionString, db_config_DBConfig::$MySQLuserName, db_config_DBConfig::$MySQLpassCode);
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
这样做之后:
$this->connection->prepare("CALL CreateRecord('testingRecord')")
它给了我以下错误:
Fatal error: Call to a member function prepare() on a non-object in
当我使用 var_dump 打印对象时,它给了我这个:
object(db_mysql_DBConnect)#1 (3) { ["connectionString":"db_mysql_DBConnect":private]=> string(70) "mysql:host=localhost;dbname=testingrecord;port=3306;connect_timeout=15" ["connection"]=> object(PDO)#2 (0) { } ["assocData":"db_mysql_DBConnect":private]=> array(0) { } }
我不确定我在这里缺少什么。任何帮助将不胜感激...