mysqli returns only one row instead of multiple rows
- by Tristan
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 ?