点击(此处)折叠或打开
- <?php
- header("Content-Type:text/html;charset=utf8");
- // PDO
- //1:
- try{
- $pdo=@new PDO('mysql:host=localhost;dbname=sakura','root','root');
- }catch(PDOException $e){
- echo $e->getMessage();
- }
- // PDO判断SQL执行结果
- $sql="delete from songs where id=9";
- $res=$pdo->exec($sql);
- if($res===false){
- // echo $pdo->errorCode();
- $errInfo=$pdo->errorInfo();
- print_r($errInfo);
- }
- // ---------------------------------------分割线------------------------------------------------
- // mysqli
- $mysqli=@new mysqli('localhost','root','root','sakura',3306);
- if($mysqli->connect_errno){
- die('Connect Error:'.$mysqli->connect_error);
- }
- $sql="delete from songs where id=9";
- if(!($mysqli->query($sql))){
- echo $mysqli->error;
- }