mysql:host=localhost;dbname=soa, 'dbuser'=>'root', 'dbpwd'=>'123456');try{ $db = new pdo($dbconn['dns'],$dbconn['dbuser'],$dbconn['dbpwd']); $db->query(set names utf8); $update = update wp_links set link_url = 'www.163.com' where link_id=1; $insert = insert into wp_links (link_url,link_name) values('www.gosoa.com.cn','scofield博客'); $db->exec($insert); echo $db->lastinsertid();}catch(pdoexception $e)
{ echo $e->getmessage();}
复制代码
exec() 函数就是来执行 insert update delete 这些操作的。而常用的select操作大多用 query函数。
以上介绍了php pdo insert与pdo insertid的用法,希望对大家有所帮助。