标签:
<?php 10 11 //造PDO对象 12 $pdo = new PDO("mysql:dbname=mydb;host=localhost","root","123"); 13 14 //写SQL语句 15 $sql = "insert into Info values(?,?,?,?,?)"; 16 17 //准备SQL语句 18 $st = $pdo->prepare($sql); 19 20 /* //给SQL语句分配变量 21 $st->bindParam(1,$code); 22 $st->bindParam(2,$name); 23 $st->bindParam(3,$sex); 24 $st->bindParam(4,$nation); 25 $st->bindParam(5,$birthday); 26 27 //给变量赋值 28 $code = "p120"; 29 $name = "接口"; 30 $sex = true; 31 $nation = "n002"; 32 $birthday = "1988-2-3"; 33 34 //执行SQL语句 35 $st->execute(); 36 37 */ 38 39 //执行SQL语句,简便方法 40 $st->execute(array(‘p030‘,‘克隆‘,true,‘n001‘,‘1989-2-3‘)); 41 42 43 44 45 46 ?>
标签:
原文地址:http://www.cnblogs.com/baozhaba-xianchong/p/5376731.html