Php 这是Mysqli中的一个bug-部分结果吗
mysqli prepare语句在执行时仅返回部分结果,即在fetch()上$hash,$type保留其值,但$userId保持为空,此问题仅出现在prepared语句中Php 这是Mysqli中的一个bug-部分结果吗,php,mysql,mysqli,Php,Mysql,Mysqli,mysqli prepare语句在执行时仅返回部分结果,即在fetch()上$hash,$type保留其值,但$userId保持为空,此问题仅出现在prepared语句中 if($statement=$this->db->prepare("SELECT `id`,`password`,`type` FROM `login` WHERE `username`=?")){ $statement->bind_param("s",$username); if($statem
if($statement=$this->db->prepare("SELECT `id`,`password`,`type` FROM `login` WHERE `username`=?")){
$statement->bind_param("s",$username);
if($statement->execute()){
$statement->bind_result($userId,$hash,$type);
if($statement->fetch()){
if(password_verify($password, $hash)){
$this->userId=$userId;
if($type=='u')
return true;
}else {
$this->error(11);
}
}else
$this->error(5);
}else
$this->error(4);
}else
$this->error(3);
我通过将id转换为CHAR解决了这个问题
SELECT CAST(`id` AS CHAR),`password`,`type` FROM `login` WHERE `username`=?
但仍然不确定为什么会发生。猜猜mysqli的bug