Blogger Information
Blog 4
fans 0
comment 0
visits 2949
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PDO连接数据库实例
ganchangbao
Original
526 people have browsed it
链接数据库
  1. $host = 'localhost';
  2. $charset = 'utf8';
  3. $dbname = 'dsw';
  4. $user = 'root';
  5. $password = 'root';
  6. $dsn = sprintf('mysql:host=%s;dbname=%s;charset:%s',$host,$dbname,$charset);
  7. 1、链接数据库
  8. $pdo = new PDO($dsn,$user,$password);
  9. 2、查询操作
  10. $sql = "select * form table where id=?";
  11. $stmt = $pdo->prepare($sql);
  12. $stmt->bindValue($id);
  13. $stmt->execute();
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post