欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          PHP中如何使用PDO修改數(shù)據(jù)?

          PHP中如何使用PDO修改數(shù)據(jù)?

          PHP中如何使用PDO修改數(shù)據(jù)?

          首先進行連接數(shù)據(jù)庫,將PDO對象進行實例化;

          $dbms = 'mysql'; $user = 'root'; $pwd = '12345678'; $dbName = 'ceshi'; $host = 'localhost'; $charset = 'utf8'; $dsn = "$dbms:host=$host;dbname=$dbName;charset=$charset"; try { $pdo = new PDO( $dsn, $user, $pwd ); } catch ( Exception $e ) { echo $e->getMessage(); }

          然后編寫一個SQL語句模板;接著使用方法“prepare()”方法,將SQL語句進行預(yù)處理;

          $sql = "select * from dunling_chat where id=? "; //準(zhǔn)備sql模板 $stmt = $pdo->prepare( $sql );

          最后進行參數(shù)綁定并執(zhí)行SQL即可。

          $id = '1'; //綁定參數(shù) $stmt->bindValue( 1, $id ); //執(zhí)行預(yù)處理語句 $stmt->execute();

          推薦教程:《PHP教程》

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號