Skip to content

Instantly share code, notes, and snippets.

@ab-budaev
Created September 12, 2021 11:21
Show Gist options
  • Save ab-budaev/08af8e952baf7d61a6720dbdb06cbeb1 to your computer and use it in GitHub Desktop.
Save ab-budaev/08af8e952baf7d61a6720dbdb06cbeb1 to your computer and use it in GitHub Desktop.
Simple gift to share it in the presentation about PDO and DB patterns
<?php
$connection = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
$statement = $connection->prepare("INSERT INTO table (col1, col2, col3) VALUES (?, ?, ?)");
$statement->bindParam(1, "value1");
$statement->bindParam(2, "value2");
$statement->bindParam(3, "value3");
// OR
$statement->execute("value1", "value2", "value3");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment