Skip to content

Instantly share code, notes, and snippets.

@YamilG
Forked from mattattui/gist:879269
Created January 5, 2013 02:08
Show Gist options
  • Save YamilG/4459215 to your computer and use it in GitHub Desktop.
Save YamilG/4459215 to your computer and use it in GitHub Desktop.
<?php
$db = new PDO('mysql:host=hostname;dbname=defaultDbName',
'username', 'password',
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$query = 'SELECT * FROM my_table WHERE title = :title';
$stmt = $db->prepare($query);
$stmt->bindValue(':title', $myTitle);
$stmt->execute();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
// ...
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment