mysqli returns only one row instead of multiple rows

Posted by Tristan on Stack Overflow See other posts from Stack Overflow or by Tristan
Published on 2010-06-10T00:38:26Z Indexed on 2010/06/10 0:42 UTC
Read the original article Hit count: 250

Filed under:
|
|

Hello,

i'm totally new to mysqli and i took a generated code and adapted it for my need.

public function getServeurByName($string) {

    $stmt = mysqli_prepare($this->connection, "SELECT DISTINCT * FROM $this->tablename where GSP_nom=?");
    $this->throwExceptionOnError();

    mysqli_stmt_bind_param($stmt, 's', $string);        
    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();

    mysqli_stmt_bind_result($stmt, 
    $row->idServ, 
    $row->timestamp,
      ...........
      ........... 
    $row->email);

    if(mysqli_stmt_fetch($stmt)) {
      $row->timestamp = new DateTime($row->timestamp);
      return $row;
    } else {
      return null;
    }
}

the problem, this example i took the template on returns only one row instead of all the records.

how to fix that please ?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about mysql-query