[Moscow.pm] escaping chars in sql

Andrew Shitov andy на shitov.ru
Пн Янв 5 13:16:08 PST 2009


Было
> $sth = $dbh->prepare("INSERT INTO t1 (f1, f2) VALUES ('$foo', '$bar')");

Стало
$sth = $dbh->prepare("INSERT INTO t1 (f1, f2) VALUES (?, ?)");
$sth->execute($foo, $bar);

?

-- 
Andrew Shitov
______________________________________________________________________
andy на shitov.ru | http://shitov.ru


Подробная информация о списке рассылки Moscow-pm