Call to undefined method PDO::execute()

在调试php的时候弹出报错

Call to undefined method Database::prepare()

Call to undefined method PdoMySQL::prepare()

解决方法:

参考链接:

https://stackoverflow.com/questions/3716798/call-to-undefined-method-databaseprepare

https://stackoverflow.com/questions/23371118/call-to-undefined-method-pdoexecute#

There is no method prepare in your Database class. That belongs to the PDO object that you are storing as $link.

What you are probably looking for is

Database :: $link->prepare(…)

部分代码段:

	public static function query($sql=''){
		$link=self::$link;
		if(!$link) return false;
		//判断之前是否有结果集,如果有的话,释放结果集
		if(!empty(self::$PDOStatement))self::free();
		self::$queryStr=$sql;
		self::$PDOStatement=$link->prepare(self::$queryStr);
		$res=self::$PDOStatement->execute();
		self::haveErrorThrowException();
		return $res;
	}
<?php
//error_reporting(0);
require_once '../model/PdoMySQL.class.php';
require_once '../model/config.php';
$username=$_GET["username"];
$pdo=new PdoMySQL();
$sql5="select username from admin";
$stmt5=$pdo::$link->prepare($sql5);
$stmt5->execute();
while($row5=$stmt5->fetch()){
    $usernames[]=$row5['username'];

}

if(in_array($username,$usernames)){
    $response="该账号已注册可"."<a href='../view/login.php'>直接登录</a>";
}
echo $response;
?>

 

转载请注明出处与链接,如有其他疑问或交流,请加QQ交流群或关注公众号加我微信

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注