Skip to content

Instantly share code, notes, and snippets.

@IvanAlekseevichPopov
Created December 21, 2017 14:40
Show Gist options
  • Save IvanAlekseevichPopov/2068d46a7060cb3bfa077ddea4046e01 to your computer and use it in GitHub Desktop.
Save IvanAlekseevichPopov/2068d46a7060cb3bfa077ddea4046e01 to your computer and use it in GitHub Desktop.
How bind IN () in PDO. And using FETCH_UNIQUE same time!
return $this
->getEntityManager()
->getConnection()
->executeQuery(
"SELECT id, concat(first_name, ' ', last_name) name, avatar FROM profiles WHERE id IN (?)",
[$userIds],
[Connection::PARAM_INT_ARRAY]
)
->fetchAll(\PDO::FETCH_UNIQUE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment