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