我未在准备好的语句mysql中使用,而我在OOP php daskite中是新来的

问题描述 投票:0回答:1

我想在我的index.php中返回u,p,d的值,但我不知道该返回什么代码

$stmt = $this->mysqli->prepare("SELECT u,p,d FROM pump_price");
$stmt->execute();
$stmt->bind_result($u,$p,$d);

while ($row = $stmt->fetch()) {
    // what to return here?
}
$stmt->close();
$this->mysqli->close();
php oop prepared-statement
1个回答
0
投票

bind_result()函数应为结果集中的每个记录提供变量upd$u$p$d的值。因此,您可以尝试以下操作:

$stmt = $this->mysqli->prepare("SELECT u, p, d FROM pump_price");
$stmt->execute();
$stmt->bind_result($u,$p,$d);

while ($row = $stmt->fetch()) {
    echo "(" . $u . ", " . $p . ", " . $d . ")" . "\n";
}
$stmt->close();
$this->mysqli->close();
© www.soinside.com 2019 - 2024. All rights reserved.