I've often created an API like this:
public function getUserInfo($id) {
$stmt = $this->conn->prepare("SELECT id, email FROM users WHERE id = ? ");
$result = array();
$stmt->bind_param("s", $id);
$stmt->execute();
$stmt->bind_result($id, $email);
$stmt->fetch();
$result['id'] = $id;
$result['email'] = $email;
return $result;
}
However, I need to develop the API using procedures. and My Code is not working.
public function getUserInfo($id) {
$stmt = $this->conn->prepare("call getUser( ? )");
$result = array();
$stmt->bind_param("s", $id);
$stmt->execute();
$stmt->bind_result($id, $email); // error here
$stmt->fetch();
$result['id'] = $id;
$result['email'] = $email;
return $result;
}
What I have to do for get id and email in this case?