Skip to content

Instantly share code, notes, and snippets.

@lorenzo
Created January 7, 2016 10:54
Show Gist options
  • Save lorenzo/be32efab83420b957f7f to your computer and use it in GitHub Desktop.
Save lorenzo/be32efab83420b957f7f to your computer and use it in GitHub Desktop.
<?php
function unsafeIN($field, $values)
{
return function ($expression) use ($field,$values) {
if (empty($values)) {
return $expression->add(['1 != 1']);
}
return $expression->in($field, $values);
};
}
// Usage:
$query->where(unsafeIN('id', $values));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment