PHP 8.3.4 Released!

mysqli::stat

mysqli_stat

(PHP 5, PHP 7, PHP 8)

mysqli::stat -- mysqli_statObtiene el estado actual del sistema

Descripción

Estilo orientado a objetos

mysqli::stat(): string

Estilo por procedimientos

mysqli_stat(mysqli $link): string

mysqli_stat() devuelve una cadena que contiene información similar a la proporcionada por el comando 'mysqladmin status'. Incluye el tiempo en funcionamiento en segundos y el número de hilos en ejecución, de preguntas, de recargas y de tablas abiertas.

Parámetros

link

Sólo estilo por procediminetos: Un identificador de enlace devuelto por mysqli_connect() o mysqli_init()

Valores devueltos

Una cadena que describe el estado del servidor. false si ocurrió un error.

Ejemplos

Ejemplo #1 Ejemplo de mysqli::stat()

Estilo orientado a objetos

<?php
$mysqli
= new mysqli("localhost", "mi_usuario", "mi_contraseña", "world");

/* comprobar la conexión */
if (mysqli_connect_errno()) {
printf("Falló la conexión: %s\n", mysqli_connect_error());
exit();
}

printf ("Estado del sistema: %s\n", $mysqli->stat());

$mysqli->close();
?>

Estilo por procedimientos

<?php
$enlace
= mysqli_connect("localhost", "mi_usuario", "mi_contraseña", "world");

/* comprobar la conexión */
if (mysqli_connect_errno()) {
printf("Falló la conexión: %s\n", mysqli_connect_error());
exit();
}

printf("Estado del sistema: %s\n", mysqli_stat($enlace));

mysqli_close($enlace);
?>

El resultado de los ejemplos sería:

Estado del sistema: Uptime: 272  Threads: 1  Questions: 5340  Slow queries: 0
Opens: 13  Flush tables: 1  Open tables: 0  Queries per second avg: 19.632
Memory in use: 8496K  Max memory used: 8560K

Ver también

add a note

User Contributed Notes 1 note

up
9
amosjohlong at hotmail dot com
7 years ago
Here is an explanation of the values that appear in connection->stat() returned string. It was taken from Ai Hua's April 29, 2006 answer on http://forums.mysql.com/read.php?12,86570,86570.

Uptime--The number of seconds the MySQL server has been running.

Threads--The number of active threads (clients).

Questions--The number of questions (queries) from clients since the server was started.

Slow queries--The number of queries that have taken more than long_query_time seconds.

Opens--The number of tables the server has opened.

Flush tables--The number of flush-*, refresh, and reload commands the server has executed.

Open tables--The number of tables that currently are open.

Queries per second avg--Questions divided by Uptime
To Top