Function 我的PDO类在执行时返回错误
我完成了向PDO的转换,并根据弹出的致命错误修改了我的系统。 ERR:在/home/a1933806/public_html/globals/server bin/php/core.php中对非对象调用成员函数execute() 行:43 这是我的设置,受影响的行以粗体显示:Function 我的PDO类在执行时返回错误,function,pdo,call,execute,member,Function,Pdo,Call,Execute,Member,我完成了向PDO的转换,并根据弹出的致命错误修改了我的系统。 ERR:在/home/a1933806/public_html/globals/server bin/php/core.php中对非对象调用成员函数execute() 行:43 这是我的设置,受影响的行以粗体显示: class netCore { private $armor; private $boot; private $dbHost = "*****.*******.com"; p
class netCore {
private $armor;
private $boot;
private $dbHost = "*****.*******.com";
private $dbNAME = "********";
private $dbPASS = "********";
private $dbUSR = "********";
private $err;
private $state;
public function __construct() {
$bootloadr = "mysql:host=".$this->dbHost.";dbname=".$this->dbNAME.";charset=UTF8";
$opt = array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
try {
$this->boot = new PDO($bootloadr, $this->dbUSR, $this->dbPASS, $opt);
} catch(PDOException $e) {
$this->err = "<b>Lebensborn® netCore™ Error:</b> An exception has been raised during Network-to-Database procedures.<br /><b>Message:</b> ".$e->getMessage().".";
}
}
public function bind($param, $value, $type = null) {
if(is_null($type)) {
switch(true) {
case is_int($value):
$type = PDO::PARAM_INT;
break;
case is_bool($value):
$type = PDO::PARAM_BOOL;
break;
case is_null($value):
$type = PDO::PARAM_NULL;
break;
default:
$type = PDO::PARAM_STR;
}
}
$this->state->bindValue($param, $value, $type);
}
public function exe() {
return $this->state->execute();
}
public function count() {
return $this->state->rowCount();
}
public function q($q) {
try {
$this->armor = $this->boot->prepare($q);
$this->state = $armor;
} catch(PDOException $e) {
$this->err = "<b>Lebensborn® netCore™ Error:</b> An exception has been raised during Network-to-Database procedures.<br /><b>Message:</b> ".$e->getMessage().".";
}
}
public function set() {
$this->exe();
return $this->state->fetchAll(PDO::FETCH_ASSOC);
}
public function single() {
$this->exe();
return $this->state->fetch(PDO::FETCH_ASSOC);
}
public function transBegin() {
return $this->boot->beginTransaction();
}
public function transCancel() {
return $this->boot->rollBack();
}
public function transEnd() {
return $this->boot->commit();
}
}
classnetcore{
私人装甲;
私人$boot;
private$dbHost=“***************.com”;
private$dbNAME=“*******”;
私有$dbPASS=“*******”;
私有$dbUSR=“**********”;
私人$err;
私人和国家;
公共函数构造(){
$bootloadr=“mysql:host=”.$this->dbHost.“dbname=”.$this->dbname.“charset=UTF8”;
$opt=array(PDO::ATTR\u PERSISTENT=>true,PDO::ATTR\u ERRMODE=>PDO::ERRMODE\u异常);
试一试{
$this->boot=newpdo($bootloader,$this->dbUSR,$this->dbPASS,$opt);
}捕获(PDO$e){
$this->err=“Lebensborn®;netCore&trade;错误:在网络到数据库过程中引发异常。
消息:“..e->getMessage()”;
}
}
公共函数绑定($param,$value,$type=null){
if(为null($type)){
开关(真){
案例为_int($value):
$type=PDO::PARAM_INT;
打破
案例为_bool($value):
$type=PDO::PARAM_BOOL;
打破
大小写为空($value):
$type=PDO::PARAM_NULL;
打破
违约:
$type=PDO::PARAM_STR;
}
}
$this->state->bindValue($param,$value,$type);
}
公共函数exe(){
返回$this->state->execute();
}
公共功能计数(){
返回$this->state->rowCount();
}
公共职能q($q){
试一试{
$this->armor=$this->boot->prepare($q);
$this->state=$armor;
}捕获(PDO$e){
$this->err=“Lebensborn®;netCore&trade;错误:在网络到数据库过程中引发异常。
消息:“..e->getMessage()”;
}
}
公共函数集(){
$this->exe();
返回$this->state->fetchAll(PDO::FETCH_ASSOC);
}
公共职能单一(){
$this->exe();
返回$this->state->fetch(PDO::fetch_ASSOC);
}
公共函数transBegin(){
返回$this->boot->beginTransaction();
}
公共函数transCancel(){
返回$this->boot->rollBack();
}
公共职能区(){
返回$this->boot->commit();
}
}
首先,如果指定的数据库连接详细信息是合法的,则放置一个假的数据库连接详细信息。尝试使用此返回$this->state->execute()
到这个返回$this->boot->execute()代码>谢谢,一切都很顺利~^^