Skip to content

Instantly share code, notes, and snippets.

@simplyniceweb
Created August 7, 2018 11:31
Show Gist options
  • Save simplyniceweb/233cf638da393abaa0f01c4b35258b92 to your computer and use it in GitHub Desktop.
Save simplyniceweb/233cf638da393abaa0f01c4b35258b92 to your computer and use it in GitHub Desktop.
Doctrine query not equal
<?php
use Doctrine\Common\Collections\Criteria;
class Classy
{
public function index()
{
$criteria = new Criteria();
$criteria->where(Criteria::expr()->neq('roles', 'ROLE_USER'));
$users = $app['orm.em']->getRepository('models\\User')->matching($criteria);
// ICYM: Making query easy.
// Finally doctrine realizes we need !=/neq
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment