-
-
$dbconn = array( - 'dns'=>"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 blog')";
- $db->exec($insert);
- echo $db->lastInsertId();
{ - echo $e->getMessage();
- }
-
-
Copy code
exec() function is to perform insert update delete operations of.
Most of the commonly used select operations use the query function.
The above introduces the usage of php pdo insert and pdo insertId. I hope it will be helpful to everyone.
|