Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine returning join query in different arrays

$query = $this->createQueryBuilder('p');
$query
    ->select('s', 'p')
    ->innerJoin(
        'test\Entity\ProductQuantity',
        's',
        \Doctrine\ORM\Query\Expr\Join::WITH,
        'p.sku = s.sku'
    )
    ->orderBy('p.productId', 'DESC');

return $query->getQuery()->getResult();

This query must return result of 2 tables, what I get:

result = array(
[0] => 'table1',
[1]=> 'table2',
[2] => 'table1',
[3]=> 'table2',
)

Why I'm get 2 tables in 2 arrays ? this is join query and it must be in 1 array, how to merge result of join query in 1 array and get:

result = array(
[0] => 'table1table2',
[1] => 'table1table2',
)
like image 428
Wizard Avatar asked Dec 20 '22 05:12

Wizard


1 Answers

You can get result as a an array by using :

$query->getQuery()->getScalarResult();
like image 189
lepix Avatar answered Jan 06 '23 12:01

lepix