I
I
Igorek982021-06-14 01:41:15
MySQL
Igorek98, 2021-06-14 01:41:15

Is it necessary to close a connection re-created through another variable?

With such a recording, should I do more at the end $sql->close()?

$mysqli = new mysqli($host,$user,$pass,$con);
$mysqli->set_charset("utf8");


if($sql = $mysqli->prepare($query)) {
$sql->bind_param("s", $value);
$sql->execute();

$mysqli->close();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AUser0, 2021-06-14
@Igorek98

No, it doesn `t need.
The $sql variable is only for storing query parameters and its results.
The connection itself is stored in $mysqli, and it needs to be closed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question