Skip to content

Instantly share code, notes, and snippets.

@amitayh
Created September 12, 2012 16:06
Show Gist options
  • Save amitayh/3707729 to your computer and use it in GitHub Desktop.
Save amitayh/3707729 to your computer and use it in GitHub Desktop.
<?php
$dbh = new PDO(/* connection details */);
$query = '
SELECT *
FROM table
WHERE col1 = :value1
AND col2 = :value2
';
$params = array(
'value1' => 'foo',
'value2' => 'bar'
);
$statement = $dbh->prepare($query);
$statement->execute($params);
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment