<?php
$pdo=new PDO("mysql:host=localhost;dbname=test","root","");//PDO连接数据库
//数据库插入操作,更新操作雷同
if($pdo->exec("insert into info(name,address,mail,sex) values('jane','hefei','abc','crown')")){
echo "插入成功";
}else{
echo "插入失败";
}
$sr=$pdo->query("select * from info");
while($row=$sr->fetch()){//数据库查询
print_r($row);
}
$row=$sr->fetchall();//数据库查询方法二
print_r($row);
?>