This commit is contained in:
as2252258@163.com
2021-05-02 14:11:54 +08:00
parent ed4c3ffc09
commit 7bef5a75a4
+9 -1
View File
@@ -196,14 +196,22 @@ class Command extends Component
return $this->addError($this->sql . ':' . $error, 'mysql'); return $this->addError($this->sql . ':' . $error, 'mysql');
} }
$result = $this->checkResponse($prepare, $connect);
$prepare->closeCursor();
return $result;
}
private function checkResponse($prepare, $connect)
{
$result = $prepare->execute($this->params); $result = $prepare->execute($this->params);
defer(fn() => $prepare->closeCursor());
if ($result === false) { if ($result === false) {
return $this->addError($connect->errorInfo()[2], 'mysql'); return $this->addError($connect->errorInfo()[2], 'mysql');
} }
return (int)$connect->lastInsertId(); return (int)$connect->lastInsertId();
} }
/** /**
* @param $modelName * @param $modelName
* @return $this * @return $this