I try to use findBy() in my controller and it only works when I use plain text and not a variable - but both are strings, for example:
$repository = $this->getDoctrine()->getRepository('SchlauchBundle:Armatur');
$armatur = $entity->getArmatur();
$armaturen = $repository->findBy(
array('nameArmatur' => $entity->getArmatur())
);
var_dump($armatur) outputs:
string(21) "Klemmschalen EN 14420"
but var_dump($armaturen) outputs:
NULL
.
When I change the findBy()-part to:
$armaturen = $repository->findBy(
array('nameArmatur' => "Klemmschalen EN 14420")
);
it works - it is so confusing me! What could be the problem that it is not possible for me to use the variable? I don't understand the difference.
In entity file it's defined (nothing special):
/**
* @var string
*/
private $nameArmatur;
Try making a trim(array('nameArmatur' => $entity->getArmatur()) to see what's the behaviour