mysql安装pdo及测试
添加支持的方法
编辑下PHP/PHP.ini文件
extension=php_pdo_mysql.dll 如有注释,去掉注释
查找 extension_dir,如果注释 去掉注释,并确认扩展目录正确
测试代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?php $dbh = new PDO( "mysql:host=localhost:3405;dbname=mysql" , "test" , "test" ); $query = "select * from user" ; $result = $dbh ->query( $query ); $rows = $result ->fetchAll(); foreach ( $rows as $row ) { $ym = $row [0]; $user = $row [1]; $ps = $row [2]; printf( "ym-" . $ym . " user-" . $user . " ps-" . $ps ); print ( "</br>" ); } $dbh = null; ?> |