1--TEST-- 2PDO::ATTR_SERVER_INFO 3--SKIPIF-- 4<?php 5require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); 6require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 7MySQLPDOTest::skip(); 8$db = MySQLPDOTest::factory(); 9?> 10--FILE-- 11<?php 12 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 13 $db = MySQLPDOTest::factory(); 14 15 assert(('' == $db->errorCode()) || ('00000' == $db->errorCode())); 16 17 $info = $db->getAttribute(PDO::ATTR_SERVER_INFO); 18 if ('' == $info) 19 printf("[001] Server info must not be empty\n"); 20 21 // Read-only? 22 if (false !== $db->setAttribute(PDO::ATTR_SERVER_INFO, 'new uptime: 0s')) 23 printf("[002] Wonderful, I can change the client version!\n"); 24 25 $new_info = $db->getAttribute(PDO::ATTR_SERVER_INFO); 26 if (soundex($new_info) != soundex($info)) 27 printf("[003] Did we change it from '%s' to '%s'?\n", $info, $info); 28 29 // lets hope we always run this in the same second as we did run the server info request... 30 if (!$stmt = $db->query("SHOW STATUS LIKE '%uptime%'")) 31 printf("[004] Cannot run SHOW STATUS, [%s]\n", $db->errorCode()); 32 else { 33 if (!$row = $stmt->fetch(PDO::FETCH_NUM)) 34 printf("[005] Unable to fetch uptime, [%s]\n", $db->errorCode()); 35 else 36 $uptime = $row[1]; 37 $stmt->closeCursor(); 38 } 39 40 if (!preg_match('/Uptime/i', $info)) 41 printf("[006] Can't find uptime in server info '%s'\n", $info); 42 43 if (isset($uptime)) { 44 if (!preg_match('/Uptime: (\d+)/i', $info, $matches) || $uptime - $matches[1] > 1) { 45 printf("[007] SHOW STATUS and server info have reported a different uptime, please check. Server info: '%s', SHOW STATUS: '%s'\n", $info, $uptime); 46 } 47 } 48 49 print "done!"; 50--EXPECT-- 51done! 52