What is the preferred way to load one record with doctrine?
I am using
$em = EntityManager::create($connectionOptions, $config);
$dql = "select r from Rolle r";
$list = $em->createQuery($dql)->getResult();
to get a list of records.
I tried using
$dql = Doctrine_Query::create()
->from('Rolle r')
->where('r.ID = 14');
$rolle = $dql->fetchArray();
to get one record. Is this the preferred way?
If yes: I get the internal server error: Class ‘Doctrine_Query’ not found in … on line …
I searched for a file which contains the string ‘Doctrine_Query’, but I haven’t such a file. So where do I find this class?
You might use
getSingleResult()instead ofgetResult(). It’s documentet in this chapter of the doctrine doc.