PHP 8.3.4 Released!

mysqli::close

mysqli_close

(PHP 5, PHP 7, PHP 8)

mysqli::close -- mysqli_closeCloses a previously opened database connection

Açıklama

Nesne yönelimli kullanım

public mysqli::close(): true

Yordamsal kullanım

mysqli_close(mysqli $mysql): true

Closes a previously opened database connection.

Open non-persistent MySQL connections and result sets are automatically closed when their objects are destroyed. Explicitly closing open connections and freeing result sets is optional. However, it's a good idea to close the connection as soon as the script finishes performing all of its database operations, if it still has a lot of processing to do after getting the results.

Bağımsız Değişkenler

bağlantı

Sadece yordamsal tarz: mysqli_connect() veya mysqli_init() işlevinden dönen bir mysqli nesnesi.

Dönen Değerler

Daima true döndürür.

Sürüm Bilgisi

Sürüm: Açıklama
8.0.0 This function now always returns true. Previously it returned false on failure.

Örnekler

Örnek 1 mysqli::close() example

Nesne yönelimli kullanım

<?php

mysqli_report
(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

$result = $mysqli->query("SELECT Name, CountryCode FROM City ORDER BY ID LIMIT 3");

/* Close the connection as soon as it's no longer needed */
$mysqli->close();

foreach (
$result as $row) {
/* Processing of the data retrieved from the database */
}

Yordamsal kullanım

<?php

mysqli_report
(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = mysqli_connect("localhost", "my_user", "my_password", "world");

$result = mysqli_query($mysqli, "SELECT Name, CountryCode FROM City ORDER BY ID LIMIT 3");

/* Close the connection as soon as it's no longer needed */
mysqli_close($mysqli);

foreach (
$result as $row) {
/* Processing of the data retrieved from the database */
}

Notlar

Bilginize:

mysqli_close() will not close persistent connections. For additional details, see the manual page on persistent connections.

Ayrıca Bakınız

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top