<?php
$dsn = ‘mysql:dbname=test;host=127.0.0.1‘;
$user = ‘root‘;
$password = ‘12345678‘;
$dbh = new PDO($dsn, $user, $password);
if(!$dbh){
exit(‘连接数据库失败‘);
}
$context = $dbh->query("select * from my_test");
$res = $context->fetchAll(PDO::FETCH_ASSOC);
var_dump($res);
$count = $dbh->exec("delete from `my_test` where my_id<150");
原文地址:http://blog.51cto.com/12173069/2094191