pdo数据保存
代码如下 | 复制代码 |
$pdo = new pdo("mysql:host=localhost;dbname=db_demo","root",""); if($pdo -> exec("insert into db_demo(name,content) values('title','content')")){ echo "插入成功!"; echo $pdo -> lastinsertid(); } ?> |
查询数据库
代码如下 | 复制代码 |
$pdo = new pdo("mysql:host=localhost;dbname=db_demo","root",""); $rs = $pdo -> query("select * from test"); while($row = $rs -> fetch()){ print_r($row); } ?> |