PDO连接数据库

Original 2019-03-28 17:46:11 153
abstract:<?php   const DSN = "mysql:host=127.0.0.1:3306;dbname=mydb";   const USER_NAME = "root";   const PASSWORD =
<?php
  const DSN = "mysql:host=127.0.0.1:3306;dbname=mydb";
  const USER_NAME = "root";
  const PASSWORD = "";
  try{
      $conn = new PDO(DSN,USER_NAME,PASSWORD);
      echo "连接成功";
  }catch (PDOException $e){
      echo $e->getMessage();
  }finally{
      $conn = null;
      echo "关闭数据库连接";
  }
?>


Correcting teacher:西门大官人Correction time:2019-03-29 09:36:51
Teacher's summary:作业写的不错,变量和常量命名很规范,见名知意。

Release Notes

Popular Entries