vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Convert mysql_stat to mysqli_stat help (https://vborg.vbsupport.ru/showthread.php?t=319330)

Falcon Capt 07-03-2015 02:03 PM

Convert mysql_stat to mysqli_stat help
 
I need to convert the following code snippets from MySQL to work with MySQLi

Code:

if ($_REQUEST['show'] == 'mysqlstats' || empty($_REQUEST['show'])) {
        print_form_header('', '');
        print_table_header('MySQL Stats &nbsp;<span class="normal">mysql_stat()</span>');
        print_description_row(si_mysqlstats());
        print_table_footer();
        }

Code:

function si_mysqlstats() {
        $s = '';
        $status = explode('  ', mysql_stat());
        while ( list($k, $v) = each($status) ) {
                $s .= $v . '<br />';
        }
        return $s;
}

Thanks for any help provided!

Dave 07-03-2015 03:06 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.php

Falcon Capt 07-03-2015 03:59 PM

Quote:

Originally Posted by Dave (Post 2549242)
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

I 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

1 Attachment(s)
OK, I got it to work (sort of) using the following code:

Code:

if ($_REQUEST['show'] == 'mysqlistats' || empty($_REQUEST['show'])) {
        print_form_header('', '');
        print_table_header('MySQLi Stats &nbsp;<span class="normal">mysqli_stat()</span>');
        print_description_row(si_mysqlistats());
        print_table_footer();
        }


Code:

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!


All times are GMT. The time now is 06:03 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01657 seconds
  • Memory Usage 1,721KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete