我经常创建这样的API:
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;
}
然而,我需要使用过程开发API。我的代码不起作用。
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;
}
在这种情况下,我需要做什么才能获得id和电子邮件?