View Full Version : Convert mysql_stat to mysqli_stat help
Falcon Capt
07-03-2015, 02:03 PM
I need to convert the following code snippets from MySQL to work with MySQLi
if ($_REQUEST['show'] == 'mysqlstats' || empty($_REQUEST['show'])) {
print_form_header('', '');
print_table_header('MySQL Stats <span class="normal">mysql_stat()</span>');
print_description_row(si_mysqlstats());
print_table_footer();
}
function si_mysqlstats() {
$s = '';
$status = explode(' ', mysql_stat());
while ( list($k, $v) = each($status) ) {
$s .= $v . '<br />';
}
return $s;
}
Thanks for any help provided!
Just change mysql_start to mysqli_start, keep in mind that the procedural style of MySQLi requires the connection link as a first argument. Refer to http://php.net/manual/en/mysqli.stat.php
Falcon Capt
07-03-2015, 03:59 PM
Just change mysql_start to mysqli_start, keep in mind that the procedural style of MySQLi requires the connection link as a first argument. Refer to http://php.net/manual/en/mysqli.stat.phpI tried all the variations I could think of still no joy, anyone care to convert the above to working MySQLi code that I can more or less cut & paste into a php file that will work?
Falcon Capt
07-03-2015, 05:45 PM
OK, I got it to work (sort of) using the following code:
if ($_REQUEST['show'] == 'mysqlistats' || empty($_REQUEST['show'])) {
print_form_header('', '');
print_table_header('MySQLi Stats <span class="normal">mysqli_stat()</span>');
print_description_row(si_mysqlistats());
print_table_footer();
}
function si_mysqlistats() {
$link = mysqli_connect("localhost", "dbusername", "dbpassword", "dbname");
printf(mysqli_stat($link));
mysqli_close($link);
return $s;
}
But it doesn't display correctly, see attached image, it is printing above the box instead of in the box.
Also, I would like the display to be:
Uptime: 49602
Threads: 4
Questions: 850693
Slow queries: 16
Opens: 3099
Flush tables: 1
Open tables: 747
Queries per second avg: 17.150
Instead of the current:
Uptime: 49602 Threads: 4 Questions: 850693 Slow queries: 16 Opens: 3099 Flush tables: 1 Open tables: 747 Queries per second avg: 17.150
Any help would be GREATLY appreciated!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.