Skip to content

Instantly share code, notes, and snippets.

@typhonius
Created April 19, 2013 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typhonius/5417569 to your computer and use it in GitHub Desktop.
Save typhonius/5417569 to your computer and use it in GitHub Desktop.
when retrieving a list of users from elsewhere with emails as a shared field this will detect if they exist in the db already
<?php
$emails = array(
// fill in emails here or use array from somewhere else
);
foreach ($emails as $mail) {
$query = "SELECT 1 FROM {users} WHERE mail = :mail";
$exists = db_query_range($query, 0, 1, array(':mail' => $mail))->fetchField();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment