Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 这是Mysqli中的一个bug-部分结果吗_Php_Mysql_Mysqli - Fatal编程技术网

Php 这是Mysqli中的一个bug-部分结果吗

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

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($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