According to Doctrine's documentation it is possible to bind parameters to a query. Example:
$qb->select('u')
->from('User u')
->where('u.id = ?1')
->orderBy('u.name', 'ASC')
->setParameter(1, 100);
Derived from this question I would like to know if it is possible to parametrize the select
and the from
statement as well? Like
$qb->select('?1')
->from('?2 u')
->where('u.id = 2')
->orderBy('u.name', 'ASC')
->setParameters(array(1 => 'mytable', 2 => 'mycolumn'));
I didn't manage to do so, but maybe I just did not know the proper way. Does anyone?