I really don't get your question completely, but what i got is you want to put a variable in 'where' inside a query for zend-framework2.
Take this for example, This query returns all student ids and names WHERE the $id is matched from table Students
$qb = $entityManager->createQueryBuilder();
$qb->select(array(
'PersonalInfo.studentId as studentId',
'PersonalInfo.name as studentName',
))
->from('Application\Entity\Students', 'PersonalInfo')
->where('PersonalInfo.studentId = :Info')
->setParameter('Info', $id);
$student = $qb->getQuery()->getScalarResult();
As you can see, in the where portion we have put :info, which is called alias, we give a value to this alias, in the setParameter
, where you can see a variable $id
. So $id
is a random variable which value can be changed. I hope this helps, If you need further instructions, let me know.