<?php
try {
$pdo = new PDO('mysql:host=localhost;dbname=meuBancoDeDados', $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare('INSERT INTO minhaTabela (nome) VALUES(:nome)');
$stmt->execute(array(
':nome' => 'Ricardo Arrigoni'
));
echo $stmt->rowCount();
} catch(PDOException $e) {
echo 'Error: ' . $e->getMessage();
?>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter