namespace griffin\UserBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="griffin\UserBundle\Entity\UserRepository")
* @ORM\Table(name="users")
*/
class User {
const STATUS_ACTIVE = 1;
const STATUS_INACTIVE = 0;
/**
* @ORM\Id
* @ORM\Column(name="id_users", type="smallint")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $idUsers;
和 Repository 类一样
namespace griffin\UserBundle\Entity;
use Doctrine\ORM\EntityRepository;
class UserRepository extends EntityRepository {
public function getAdmin()
{
return $this->getEntityManager()
->createQuery('select * from users where users_groups_id = 1')
->getResults;
}
}
当我在我的控制器中调用它时
$results = $this->getDoctrine()
->getRepository('griffin\UserBundle\Entity\UserRepository')
->getAdmin();
var_dump($results);
我有错误
Class "griffin\UserBundle\Entity\UserRepository" sub class of "Doctrine\ORM\EntityRepository" is not a valid entity or mapped super class.