gpt4 book ai didi

php - 从 MYSQLi 准备好的语句中获取查询

转载 作者:行者123 更新时间:2023-11-29 06:13:16 25 4
gpt4 key购买 nike

我准备好的声明如下所示:

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";

// prepare and bind
$stmt = $conn->prepare("INSERT INTO `devices` (`deviceName`, `type`, `deviceToken`) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $deviceName, $deviceToken, $type);
$stmt->execute();
echo "executed";
$result = $stmt->get_result();
$conn->close();

我想回应查询。我知道 PDO 方法:

$binded_query = $stmt->queryString

但是我需要用到MYSQLi。
那我该怎么做呢?

最佳答案

$sql = "INSERT INTO `devices` (`deviceName`, `type`, `deviceToken`) VALUES (?, ?, ?)"
$stmt = $conn->prepare($sql);
echo $sql; // here you go

关于php - 从 MYSQLi 准备好的语句中获取查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37248625/

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