Link to home
Start Free TrialLog in
Avatar of jeff_zucker
jeff_zucker

asked on

PHP PDO statements

Is there any risk in using integers (and other hardcoded variables) in PDO statments?

ie
$STH=$DBH->prepare("SELECT name FROM Employees WHERE active=1");
$STH->execute();

Seems like it would be a lot of hassle to write it like this:
$STH=$DBH->prepare("SELECT name FROM Employees WHERE active=:active_status");
$STH->execute(array(':active_status'=>1));

(Also, is my syntax ok in the 2nd example?)
SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jeff_zucker
jeff_zucker

ASKER

Two great answers.  Thank you.
Glad to help; thanks for using E-E and best of luck with your project, ~Ray