使用 PHP 服务创建重复记录
在什么情况下以下行会创建两条记录而不是一条?
该线路只运行一次,我跟踪程序以确保。
createIndcsfResult.token = indcsfService.createIndcsf(indCSF2);
标准服务
/**
* Returns the item corresponding to the value specified for the primary key.
*
* Add authorization or any logical checks for secure access to your data
*
*
* @return stdClass
*/
public function createIndcsf($item) {
$stmt = mysqli_prepare($this->connection, "INSERT INTO $this->tablename (indcsf_name, indcsf_yourcsf_id, indcsf_status) VALUES (?, ?, ?)");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sis', $item->indcsf_name, $item->indcsf_yourcsf_id, $item->indcsf_status);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
$autoid = mysqli_stmt_insert_id($stmt);
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $autoid;
}
Under what circumstances will the following line create two records instead of one?
The line only runs once, I traced the program to make sure.
createIndcsfResult.token = indcsfService.createIndcsf(indCSF2);
Standard Service
/**
* Returns the item corresponding to the value specified for the primary key.
*
* Add authorization or any logical checks for secure access to your data
*
*
* @return stdClass
*/
public function createIndcsf($item) {
$stmt = mysqli_prepare($this->connection, "INSERT INTO $this->tablename (indcsf_name, indcsf_yourcsf_id, indcsf_status) VALUES (?, ?, ?)");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sis', $item->indcsf_name, $item->indcsf_yourcsf_id, $item->indcsf_status);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
$autoid = mysqli_stmt_insert_id($stmt);
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $autoid;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论