标签:style blog color os io ar div cti log
try { $dsn = "mysql:host=127.0.0.1;port=3306;dbname=dab"; $pdo = new PDO($dsn, ‘root‘, ‘‘); $pdo -> setAttribute(PDO::ATTR_AUTOCOMMIT, false); $pdo -> beginTransaction(); $sql = "update DAB_NTOS_ADMIN set name = :name where id = :id"; $sth = $pdo->prepare($sql); $sth ->bindValue(‘:name‘, ‘KILL‘); $sth ->bindValue(‘:id‘, 3); $flag = $sth-> execute(); // true or false echo $flag; $pdo -> commit(); } catch (Exception $e) { if ($pdo) $pdo -> rollBack(); } finally { $pdo = null; }
* finally在php5.5支持,老版本不支持
标签:style blog color os io ar div cti log
原文地址:http://www.cnblogs.com/gabin/p/3934440.html