Skip to content

Instantly share code, notes, and snippets.

@wallacesilva
Created May 12, 2016 14:33
Show Gist options
  • Save wallacesilva/1140551047bced8ec7c426d767d869a8 to your computer and use it in GitHub Desktop.
Save wallacesilva/1140551047bced8ec7c426d767d869a8 to your computer and use it in GitHub Desktop.
Example using PDO PHP - bindParam - Reference to variables
<?php
$stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (?, ?)");
$stmt->bindParam(1, $name);
$stmt->bindParam(2, $value);
// insert one row
$name = 'one';
$value = 1;
$stmt->execute();
// insert another row with different values
$name = 'two';
$value = 2;
$stmt->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment