gpt4 book ai didi

php - 在 mysqli 准备语句中循环时

转载 作者:行者123 更新时间:2023-12-04 05:53:33 26 4
gpt4 key购买 nike

<分区>

是否有可能像我们在正常的 mysqli 查询中那样在准备好的语句中做一些事情。例如

$sql = "SELECT * FROM users"*;
$query = mysqli_query($link, $sql);
while($row = mysqli_fetch_assoc($query)){
echo $row['username'];
echo $row['name'];
}

在准备好的语句中,它是这样的

$fetch_comments = $friend_zone->prepare("SELECT item_poster, comment FROM status_comments WHERE status_id = ? and item_poster = ?");
$fetch_comments->bind_param("is", $status__id, $item_poster);
$fetch_comments->execute();
$fetch_comments->store_result();
$fetch_comments->bind_result($item_poster_fetched, $comment_fetched);
while($fetch_comments->fetch(){
echo $item_poster;
}

我的意思是我想像这样做 echo

echo $row['something'];

我现在想到的解决方案是使用绑定(bind)结果获取它们,然后将它们放入循环内的数组中,然后是 foo['bar']; 或类似的东西。有没有更好的办法?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com