点击(此处)折叠或打开

  1. <?php
  2. header("Content-Type:text/html;charset=utf8");
  3. // PDO
  4. //1:
  5. try{
  6.     $pdo=@new PDO('mysql:host=localhost;dbname=sakura','root','root');
  7. }catch(PDOException $e){
  8.     echo $e->getMessage();
  9. }
  10. // PDO判断SQL执行结果
  11. $sql="delete from songs where id=9";
  12. $res=$pdo->exec($sql);
  13. if($res===false){
  14. // echo $pdo->errorCode();
  15.     $errInfo=$pdo->errorInfo();
  16.     print_r($errInfo);
  17. }

  18. // ---------------------------------------分割线------------------------------------------------
  19. // mysqli
  20. $mysqli=@new mysqli('localhost','root','root','sakura',3306);
  21. if($mysqli->connect_errno){
  22.     die('Connect Error:'.$mysqli->connect_error);
  23. }
  24. $sql="delete from songs where id=9";
  25. if(!($mysqli->query($sql))){
  26.     echo $mysqli->error;
  27. }


09-17 15:12