我最近才开始研究 pdo,因为我已经坚持使用 mysql 太久了。现在我正在将一些脚本翻译成 PDO。
这对注射完全安全吗?
$name = isset($_GET['name']) ? $_GET['name'] : null;
$stmt = $db->prepare("SELECT id,name FROM users WHERE name = '$name'");
$stmt->execute();
$row = $stmt->fetch();
$stmt = $db->query("SELECT *, tr.name, t.name AS teamName FROM player AS p
LEFT JOIN team_ranks AS tr ON tr.id = p.rank_id
LEFT JOIN teams AS t on t.id = tr.team_id
WHERE p.id = {$row['id']}");
$row = $stmt->fetch();