许多mysqli连接关闭?

时间:2018-05-16 11:28:07

标签: php mysql mysqli

我有一个我需要很多选择的PHP,比如10,所以我这样做:

$stmt = $mysqli_->prepare("SELECT count(id) as num FROM table WHERE id=?");
$stmt->bind_param('i', $id);
$stmt->execute();
$stmt->bind_result($count);
$stmt->fetch();
$stmt->close();

$stmt = $mysqli_->prepare("SELECT count(id) as num FROM table2 WHERE id=?");
$stmt->bind_param('i', $id);
$stmt->execute();
$stmt->bind_result($count2);
$stmt->fetch();
$stmt->close();

$stmt = $mysqli_->prepare("SELECT count(id) as num FROM table3 WHERE id=?");
$stmt->bind_param('i', $id);
$stmt->execute();
$stmt->bind_result($count3);
$stmt->fetch();
$stmt->close();

...

可以一直使用$stmt->close();还是会破坏连接性能?

0 个答案:

没有答案