2
namespace Quindimotos\ProyectoBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\EntityRepository;

class asignarEmpleadoAServicioType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder->add('ciudad', 'entity', array(
            'empty_value' => 'Seleccione Empleado',
            'class' => 'QuindimotosProyectoBundle:empleado',
            'property_path' => false,
            'query_builder' => function (EntityRepository $er) {
                return $er->createQueryBuilder('e')
                                ->join('e.cargo', 'c')
                                ->from('QuindimotosProyectoBundle:Revision', 'r')
                                ->join('r.empleado', 'e1')
                                ->where('c.nombre =:cargo and r.empleado is not null')
                                ->setParameter('cargo', 'tecnico');
            }
        ))
        ->add('Revision', 'entity', array(
            'empty_value' => 'Seleccione Revision Disponible',
            'class' => 'QuindimotosProyectoBundle:revision',
            'property_path' => false,
            'query_builder' => function (EntityRepository $er) {
                return $er->createQueryBuilder('r')

                                ->where('r.recividopor is  null');

            }));

    }
    public function getName() {
        return 'contact';
    }
}

在下一行我不知道为什么它不起作用

->where('c.nombre =:cargo and r.empleado is null')

where 可以但条件“为空”的子句没有显示任何内容,但我知道有一些东西要显示。

在这一行中,这个子句 where is ok and "is null" 运行良好

->where('r.recividopor is  null');

有人可以告诉我这是怎么回事。

4

1 回答 1

0

当使用常规运算符将值与“null”值进行比较时,将导致结果集为空,因为比较不会产生布尔值(而是返回 NULL)

您必须避免比较,一种方法是:SELECT IFNULL(e.cargo,0) AS e.cargo然后您可以在 where 子句中使用它c.nomber = e.cargo

于 2013-02-28T21:00:45.903 回答