//查询语句
$sql = select * from lamp_login;$stmt = $pdo->query($sql);
//增 删 改
$pdo->exec($sql);
pdo::fetch_obj相当于mysql_fetch_object
object(stdclass)[3] public 'id' =>string'1'(length=1) public 'username' =>string'user1'(length=5) public 'password' =>string'123'(length=3)
pdo::fetch_both相当于mysql_fetch_array
array(size=6) 'id' =>string'2'(length=1) 0 =>string'2'(length=1) 'username' =>string'user2'(length=5) 1 =>string'user2'(length=5) 'password' =>string'234'(length=3) 2 =>string'234'(length=3)
pdo::fetch_num相当于mysql_fetch_row
array(size=3) 0 =>string'3'(length=1) 1 =>string'user3'(length=5) 2 =>string'345'(length=3)
pdo::fetch_assoc相当于mysql_fetch_assoc
array(size=3) 'id' =>string'4'(length=1) 'username' =>string'zhouyao'(length=7) 'password' =>string'123456'(length=6)
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了mysql pdo连接与操作,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。