⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mysqli_get_client_stats.phpt

📁 linux下安装不上mysql5与php5的可用此关联
💻 PHPT
📖 第 1 页 / 共 2 页
字号:
            printf("[%03d] ALTER SERVER failed, [%d] %s\n", ++$test_counter,                 mysqli_errno($link), mysqli_error($link));                        if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))            printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",                 ++$test_counter, gettype($new_info), $new_info);        mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'ALTER SERVER');        $info = $new_info;                if (!mysqli_query($link, "DROP SERVER myself"))            printf("[%03d] DROP SERVER failed, [%d] %s\n", ++$test_counter,                 mysqli_errno($link), mysqli_error($link));                        if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))            printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",                 ++$test_counter, gettype($new_info), $new_info);        mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DROP SERVER');        $info = $new_info;    }        /*    We don't test the NDB ones.    13.1. Data Definition Statements           13.1.3. ALTER LOGFILE GROUP Syntax    13.1.4. ALTER TABLESPACE Syntax                13.1.9. CREATE LOGFILE GROUP Syntax    13.1.10. CREATE TABLESPACE Syntax       13.1.15. DROP LOGFILE GROUP Syntax    13.1.16. DROP TABLESPACE Syntax        */        //    // DML    //    if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))            printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",                 ++$test_counter, gettype($new_info), $new_info);            $info = $new_info;        if (!mysqli_query($link, "INSERT INTO test(id) VALUES (100)"))        printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))        printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",             ++$test_counter, gettype($new_info), $new_info);    mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'INSERT');    $info = $new_info;        if (!mysqli_query($link, "UPDATE test SET label ='z' WHERE id = 100"))        printf("[%03d] UPDATE failed, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))        printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",             ++$test_counter, gettype($new_info), $new_info);    mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'UPDATE');    $info = $new_info;        if (!mysqli_query($link, "REPLACE INTO test(id, label) VALUES (100, 'b')"))        printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))        printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",             ++$test_counter, gettype($new_info), $new_info);    mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'REPLACE');    $info = $new_info;        // NOTE: this will NOT update dbl_ddls counter    if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100"))        printf("[%03d] SELECT@dml failed, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                mysqli_free_result($res);                if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))        printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",             ++$test_counter, gettype($new_info), $new_info);    mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, $info, $test_counter, 'SELECT@dml');    $info = $new_info;        if (!mysqli_query($link, "DELETE FROM test WHERE id = 100"))        printf("[%03d] DELETE failed, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))        printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",             ++$test_counter, gettype($new_info), $new_info);    mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DELETE');    $info = $new_info;           if (!$res = mysqli_query($link, "TRUNCATE TABLE test"))        printf("[%03d] TRUNCATE failed, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                            if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))        printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",             ++$test_counter, gettype($new_info), $new_info);    mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'TRUNCATE');    $info = $new_info;        $file = tempnam(sys_get_temp_dir(), 'mysqli_test');    if ($fp = fopen($file, 'w')) {        @fwrite($fp, '1;"a"');        fclose($fp);        chmod($file, 0644);        $sql = sprintf('LOAD DATA LOCAL INFILE "%s" INTO TABLE test', mysqli_real_escape_string($link, $file));        if (mysqli_query($link, $sql)) {            if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))                printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",                     ++$test_counter, gettype($new_info), $new_info);            mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'LOAD DATA LOCAL');            $info = $new_info;        }                unlink($file);    }        /*    We skip those:    13.2. Data Manipulation Statements     13.2.2. DO Syntax    13.2.3. HANDLER Syntax        13.2.5. LOAD DATA INFILE Syntax        */    mysqli_query($link, "DELETE FROM test");    if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b')"))        printf("[%03d] Cannot insert new records, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                    if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))        printf("[%03d] Cannot SELECT with mysqli_real_query(), [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                        if (!is_object($res = mysqli_use_result($link)))        printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                    while ($row = mysqli_fetch_assoc($res))        ;    mysqli_free_result($res);    if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))        printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",             ++$test_counter, gettype($new_info), $new_info);    mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, (string)($info['unbuffered_sets'] + 1), $test_counter, 'mysqli_use_result()');    $info = $new_info;            if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))        printf("[%03d] Cannot SELECT with mysqli_real_query() II, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                        if (!is_object($res = mysqli_store_result($link)))        printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,             mysqli_errno($link), mysqli_error($link));                    while ($row = mysqli_fetch_assoc($res))        ;    mysqli_free_result($res);    if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))        printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",             ++$test_counter, gettype($new_info), $new_info);    mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()');    $info = $new_info;            /*    no_index_used    bad_index_used    flushed_normal_sets    flushed_ps_sets      explicit_close    implicit_close    disconnect_close    in_middle_of_command_close    explicit_free_result    implicit_free_result    explicit_stmt_close    implicit_stmt_close    */    print "done!";?>--EXPECTF--array(33) {  ["bytes_sent"]=>  string(1) "0"  ["bytes_received"]=>  string(1) "0"  ["packets_sent"]=>  string(1) "0"  ["packets_received"]=>  string(1) "0"  ["protocol_overhead_in"]=>  string(1) "0"  ["protocol_overhead_out"]=>  string(1) "0"  ["result_set_queries"]=>  string(1) "0"  ["non_result_set_queries"]=>  string(1) "0"  ["no_index_used"]=>  string(1) "0"  ["bad_index_used"]=>  string(1) "0"  ["buffered_sets"]=>  string(1) "0"  ["unbuffered_sets"]=>  string(1) "0"  ["ps_buffered_sets"]=>  string(1) "0"  ["ps_unbuffered_sets"]=>  string(1) "0"  ["flushed_normal_sets"]=>  string(1) "0"  ["flushed_ps_sets"]=>  string(1) "0"  ["rows_fetched_from_server"]=>  string(1) "0"  ["rows_fetched_from_client"]=>  string(1) "0"  ["rows_skipped"]=>  string(1) "0"  ["copy_on_write_saved"]=>  string(1) "0"  ["copy_on_write_performed"]=>  string(1) "0"  ["command_buffer_too_small"]=>  string(1) "0"  ["connect_success"]=>  string(1) "0"  ["connect_failure"]=>  string(1) "0"  ["connection_reused"]=>  string(1) "0"  ["explicit_close"]=>  string(1) "0"  ["implicit_close"]=>  string(1) "0"  ["disconnect_close"]=>  string(1) "0"  ["in_middle_of_command_close"]=>  string(1) "0"  ["explicit_free_result"]=>  string(1) "0"  ["implicit_free_result"]=>  string(1) "0"  ["explicit_stmt_close"]=>  string(1) "0"  ["implicit_stmt_close"]=>  string(1) "0"}done!--UEXPECTF--array(33) {  [u"bytes_sent"]=>  unicode(1) "0"  [u"bytes_received"]=>  unicode(1) "0"  [u"packets_sent"]=>  unicode(1) "0"  [u"packets_received"]=>  unicode(1) "0"  [u"protocol_overhead_in"]=>  unicode(1) "0"  [u"protocol_overhead_out"]=>  unicode(1) "0"  [u"result_set_queries"]=>  unicode(1) "0"  [u"non_result_set_queries"]=>  unicode(1) "0"  [u"no_index_used"]=>  unicode(1) "0"  [u"bad_index_used"]=>  unicode(1) "0"  [u"buffered_sets"]=>  unicode(1) "0"  [u"unbuffered_sets"]=>  unicode(1) "0"  [u"ps_buffered_sets"]=>  unicode(1) "0"  [u"ps_unbuffered_sets"]=>  unicode(1) "0"  [u"flushed_normal_sets"]=>  unicode(1) "0"  [u"flushed_ps_sets"]=>  unicode(1) "0"  [u"rows_fetched_from_server"]=>  unicode(1) "0"  [u"rows_fetched_from_client"]=>  unicode(1) "0"  [u"rows_skipped"]=>  unicode(1) "0"  [u"copy_on_write_saved"]=>  unicode(1) "0"  [u"copy_on_write_performed"]=>  unicode(1) "0"  [u"command_buffer_too_small"]=>  unicode(1) "0"  [u"connect_success"]=>  unicode(1) "0"  [u"connect_failure"]=>  unicode(1) "0"  [u"connection_reused"]=>  unicode(1) "0"  [u"explicit_close"]=>  unicode(1) "0"  [u"implicit_close"]=>  unicode(1) "0"  [u"disconnect_close"]=>  unicode(1) "0"  [u"in_middle_of_command_close"]=>  unicode(1) "0"  [u"explicit_free_result"]=>  unicode(1) "0"  [u"implicit_free_result"]=>  unicode(1) "0"  [u"explicit_stmt_close"]=>  unicode(1) "0"  [u"implicit_stmt_close"]=>  unicode(1) "0"}done!

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -