狮子座男

导航

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; 

posted on 2014-07-25 14:17  狮子座男  阅读(483)  评论(0编辑  收藏  举报