Home | Mirror | Search |
pdo_mysql测试代码
<?php $dbms ="mysql"; $db_host="192.168.2.10"; $db_name="example"; $db_user="www"; $db_pwd="www"; $dsn="$dbms:host=$db_host;dbname=$db_name"; try { $start = microtime(); $dbh=new PDO($dsn,$db_user,$db_pwd); # $dbh->query("select * from files order by id desc limit 10″); foreach($dbh->query('SELECT id, username from members limit 10') as $row) { print_r($row); } $dbh = null; $end = microtime(); $starttime = explode(" ", $start); $endtime = explode(" ", $end); $exectime=$endtime[0]+$endtime[1]-$starttime[0]-$starttime[1]; echo "执行时间为:" . $exectime; } catch (PDOException $e) { print("Error:".$e->getMessage()); } ?>