3

私はこのコードを使用しています

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;

    }

setParametrbindValue物事は機能していません。しかし、私が置くだけisActive=1で、それは動作します

4

1 に答える 1

5

次のように、パラメーターの前にコロンを追加する必要があります。

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

setParameterこれは、コロンが不要なPDO 接続ドライバーの実装と Doctrine 関数の違いです。

于 2012-08-06T09:25:27.567 に答える