There is no problem with the database connection. The execution of $pdo->exec($sql) should have data but it does not take effect.
PHP小白
PHP小白 2019-05-29 17:38:39
0
0
1143
<?php

require 'pdo_config.php';
$dsn = "{$dbType}:host={$host};dbName={$dbName}}";// 创建数据源
try{	
    $pdo = new PDO ($dsn,$userName,$password);   
    $sql = "update student set grade=80 where id=7";
       $num = $pdo->exec($sql);//返回受影响的记录数量
       if($num>0){
    	print '成功添加';
    }else{
    	print '不成功';
    }
   
}
catch(PDOexception $e){
    die('操作失败'.$e->getMessage());
}


PHP小白
PHP小白

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template