pdo防注入原理

2018-06-20  本文已影响25人  liamu
<?php
$pdo = new PDO('mysql:host=172.16.130.67;dbname=share;charset=gbk','root','root');

// 方式一
// $st = $pdo->prepare('select * from nav where alias =\'manage\'');

// 方式二
/*
$st = $pdo->prepare('select * from nav where alias = ?');
$alias = 'manage';
$st->bindParam(1,$alias);
*/

// 方式三
$pdo->query('SET NAMES gbk'); 
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);
$st = $pdo->prepare('select * from nav where alias = ?');
$alias = 'manage';
$st->bindParam(1,$alias);

$st->execute();
print_r($st->fetchAll());


上一篇 下一篇

猜你喜欢

热点阅读