Is there possible to use createQueryBuilder for insert/update? If not, what function should I use?

前端 未结 4 1137
离开以前
离开以前 2020-12-14 04:03

For now I succeded to create a function that retrieves data from the database using Doctrine\'s function createQueryBuilder.

Does anybody know if there is a similar

4条回答
  •  -上瘾入骨i
    2020-12-14 04:18

    If you use DBAL queryBuilder, it is possible to insert.

    $qb = $connection->createQueryBuilder();
    

    To insert with the queryBuilder it is like this :

    $qb->insert('MuBundle:MyClass', 'momc')
       ->values (array(
           'property1 (id for example)' => '?'
           'property2 (name for exmaple)' => '?'
       ))
       ->setParameter(0, $id)
       ->setparameter(1, $name)
    

提交回复
热议问题