PDO::prepare语法:
PDO::prepare ( string $statement [, array $driver_options = array() ] )
方式一:
$sql="select * from news where author=:author and title=:title";
$prepare=$db->prepare($sql,array(PDO::ATTR_CURSOR,PDO::CURSOR_FWDONLY));
$prepare->execute(array(":author"=>"zyf",":title"=>"title"));//添加条件数据
$table = $prepare->fetchAll();
方式二:
$sql="select * from news where author=? and title=?";
$prepare=$db->prepare($sql);
$prepare->execute(array("zyf","title"));//添加条件数据
$table = $prepare->fetchAll();