首页 > 代码库 > PDO beginTransaction (),exec(),commit ()

PDO beginTransaction (),exec(),commit ()

 

 

    $dsn = ‘sqlsrv:server=.\SQLExpress;Database=thinkphp‘;    $user = ‘admin‘;    $password = ‘pass1234‘;    try {        $conn = new PDO($dsn, $user, $password);    } catch (PDOException $e) {        echo ‘Connection failed: ‘ . $e->getMessage();    }    $conn -> beginTransaction ();    $conn ->exec("create table think_form(        id int identity(1,1) Not Null,        title varchar(255) Not Null,        content varchar(255) Not Null,        create_time datetime Not Null,        Primary Key(id))        ");     $conn -> commit ();     $conn = null;