I am wondering exactly what are the benefits of using the doctrine to create queries, such as:
<?php // $qb instanceof QueryBuilder $qb->select('u') ->from('User u') ->where('u.id = :identifier') ->orderBy('u.name ASC'); ->setParameter('identifier', 100); // Sets :identifier to 100, and thus we will fetch a user with u.id = 100
The only advantage I see here is data sanitization and parameter binding, which can be easily done with PDO.
One more example:
<?php // $qb instanceof QueryBuilder // example8: QueryBuilder port of: "SELECT u FROM User u WHERE u.id = ? OR u.nickname LIKE ? ORDER BY u.surname DESC" using Expr class $qb->add('select', new Expr\Select(array('u'))) ->add('from', new Expr\From('User', 'u')) ->add('where', $qb->expr()->orX( $qb->expr()->eq('u.id', '?1'), $qb->expr()->like('u.nickname', '?2') )) ->add('orderBy', new Expr\OrderBy('u.name', 'ASC'));
Are additional dependencies really worth the cost of execution? The above syntax seems to me more complicated than a simple line containing a query.
source share