教义2如何从选择查询中插入表值

时间:2018-08-29 15:24:53

标签: select doctrine-orm insert setvalue

我需要按准则2查询生成器应用此查询:

INSERT INTO orders 
(status_id, menu_id, daily_balance_id)
VALUES
(1, 2, (SELECT id FROM daily_balances WHERE end_time IS NULL));

有什么帮助吗?!

1 个答案:

答案 0 :(得分:0)

也许是吗?

    $em = $this->getDoctrine()->getManager();
        $RAW_QUERY = "INSERT INTO orders 
(status_id, menu_id, daily_balance_id)VALUES(1, 2, (SELECT id FROM daily_balances WHERE end_time IS NULL));"; 
        $statement = $em->getConnection()->prepare($RAW_QUERY);
        $statement->execute();
        $qua = $statement->fetchAll();