What types do the "quote_id" columns have (in your DB)?

How are the "quoteId" properties mapped (in your entities)?

PS: I see you're hydrating entities, but with only 1 property (meaning you'll 
get partial entities). I think you'll be better of with a plain array as result 
in this case:

    $rsm = new ResultSetMapping();
    $rsm->addScalarResult('p_quote_id', 'productQuoteId');
    $rsm->addScalarResult('s_quote_id', 'serviceQuoteId');

    $sql = '(SELECT p.quote_id AS p_quote_id FROM order_products AS p) UNION 
(SELECT s.quote_id AS s_quote_id FROM order_services AS s)';

    $query = $this->em->createNativeQuery($sql, $rsm);
    $query->getScalarResult();

--  
Jasper N. Brouwer
(@jaspernbrouwer)


On 7 October 2014 at 16:31:20, MAYANK AWASTHI ([email protected]) wrote:
> I want to combine the results of 2 tables.Query is:
>  
> $sql = "(SELECT p.quote_id FROM order_products p ) UNION (SELECT s.quote_id 
> FROM order_services  
> s ) ";
>  
> I have used native sql which is:
>  
> $rsm = new ResultSetMapping();
> $rsm->addEntityResult('\Admin\Entity\OrderProducts', 'p');
> $rsm->addEntityResult('\Admin\Entity\OrderServices', 's');
> $rsm->addFieldResult('p', 'quote_id', 'quoteId');
> $rsm->addFieldResult('s', 'quote_id', 'quoteId');
>  
> $query = $this->em->createNativeQuery($sql, $rsm);
> $query->getResult();
>  
> It is showing this error:
>  
> Unknown column type "" requested. Any Doctrine type that you use has to be 
> registered  
> with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the 
> known types  
> with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during 
> database  
> introspection then you might have forgot to register all database types for a 
> Doctrine  
> Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom 
> types  
> implement Type#getMappedDatabaseTypes(). If the type name is empty you might 
> have  
> a problem with the cache or forgot some mapping information.
>  
> I am new to native sql so any better solution/suggestion will be highly
> appreciated.


-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to