我可以在学说ORM中使用prepare语句吗?

I am using this code

public function addTasks()
    {
        $stmt = $this->getEntityManager()
                    ->getConnection()
                    ->prepare('INSERT into newTasks (tasks_id, Profile_id)
                                        SELECT task.id, 3 as Profile_id
                                        FROM ptasks where ptasks.isActive = :mid');


        $stmt ->setParameter('mid',1);
        //$stmt->bindValue('foobar ', 1);
        $stmt->execute();
        return true;

    }

Now setParametr and bindValue thing is not working. However if i just put isActive=1 , then it works

You need to add a colon in front of the parameter like this:

$stmt->setParameter(':mid',1);

This is the difference between the PDO connection driver implementation and Doctrine setParameter function where the colon is not needed.