Skip to content

Instantly share code, notes, and snippets.

@MasterHans
Last active October 21, 2016 12:17
Show Gist options
  • Save MasterHans/115bb9a3bc5e713e162a1a81a6dbecee to your computer and use it in GitHub Desktop.
Save MasterHans/115bb9a3bc5e713e162a1a81a6dbecee to your computer and use it in GitHub Desktop.
<?php
$pdo = new PDO('sqlite:/path/db/users.db');
$stmt = $pdo->prepare('SELECT name FROM users WHERE id = :id');
$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();
@fedorovanton
Copy link

Круто!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment