Skip to content

Commit

Permalink
Update 07-03-01-Databases_PDO.md
Browse files Browse the repository at this point in the history
  • Loading branch information
aykutfarsak committed Jan 22, 2015
1 parent 2d3b426 commit 0a78e24
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion _posts/07-03-01-Databases_PDO.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ FROM users` which will delete all of your users! Instead, you should sanitize th
<?php
$pdo = new PDO('sqlite:/path/db/users.db');
$stmt = $pdo->prepare('SELECT name FROM users WHERE id = :id');
$id = filter_input(FILTER_GET, 'id', FILTER_SANITIZE_NUMBER_INT); // <-- filter your data first (see [Data Filtering](#data_filtering)), especially important for INSERT, UPDATE, etc.
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT); // <-- filter your data first (see [Data Filtering](#data_filtering)), especially important for INSERT, UPDATE, etc.
$stmt->bindParam(':id', $id, PDO::PARAM_INT); // <-- Automatically sanitized for SQL by PDO
$stmt->execute();
{% endhighlight %}
Expand Down

0 comments on commit 0a78e24

Please sign in to comment.