Php Insert\u id无法返回值
有人能看到下面的代码有什么问题吗?由于某些原因,我可以让它返回受影响行的id。事实上,它不会返回任何内容,但查询运行正常,并且记录在数据库中创建Php Insert\u id无法返回值,php,insert,mysqli,Php,Insert,Mysqli,有人能看到下面的代码有什么问题吗?由于某些原因,我可以让它返回受影响行的id。事实上,它不会返回任何内容,但查询运行正常,并且记录在数据库中创建 $stmt = $this->db->stmt_init(); if($stmt->prepare('INSERT INTO Assets(id,assetName,type, username, password, mail) VALUES (?,?,?,?,?,?)')) {
$stmt = $this->db->stmt_init();
if($stmt->prepare('INSERT INTO Assets(id,assetName,type, username, password, mail) VALUES (?,?,?,?,?,?)'))
{
$stmt->bind_param("isssss", $id, $assetName, $type, $username, $password, $mail);
$stmt->execute();
$stmt->close();
return $stmt->insert_id;
}
else
{
$stmt->close();
return "";
}
在尝试获取插入id之前,您正在关闭语句:
$stmt->close();
return $stmt->insert_id;
在尝试获取插入id之前,您正在关闭语句:
$stmt->close();
return $stmt->insert_id;
没关系,我只是注意到我在返回前正在关闭声明…没关系,我只是注意到我在返回前正在关闭声明。。。