<?php //造PDO对象 $pdo = new PDO("mysql:dbname=mydb;host=localhost","root","123"); //写SQL语句 $sql = "insert into Info values(?,?,?,?,?)"; //准备SQL语句 $st = $pdo->prepare($sql); /* //给SQL语句分配变量 $st->bindParam(1,$code); $st->bindParam(2,$name); $st->bindParam(3,$sex); $st->bindParam(4,$nation); $st->bindParam(5,$birthday); //给变量赋值 $code = "p120"; $name = "接口"; $sex = true; $nation = "n002"; $birthday = "1988-2-3"; //执行SQL语句 $st->execute(); */ //执行SQL语句,简便方法 $st->execute(array('p030','克隆',true,'n001','1989-2-3')); ?>