How to get a one-dimensional scalar array as a doctrine dql query result?

后端 未结 5 1530
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 06:20

I want to get an array of values from the id column of the Auction table. If this was a raw SQL I would write:

SELECT id FROM auction

But w

5条回答
  •  臣服心动
    2020-12-02 07:04

    I think it's impossible in Doctrine. Just transform result array into the data structure you want using PHP:

    $transform = function($item) {
        return $item['id'];
    };
    $result = array_map($transform, $em->createQuery("SELECT a.id FROM Auction a")->getScalarResult());
    

提交回复
热议问题