In a word, no.
In a UNION, MySQL does not return any table information with each
column [since it can't, because a union can be from different tables],
and cakephp's dbo_mysql class relies on this information to map the
result rows to the originating model (think left joins).
What exactly is the query you're trying to produce? There must be a
way to rewrite it to not use a union (which are not usually that
efficient anyway).
If the union query you're creating is from the same table, you could
always perform the union as a query(), but only return the row ids,
then use Set::extract() on the result to get the ids into a flattened
list, then call findAll with the id list:
$tmp = $this->query('SELECT Product.id FROM [complicated sql] UNION
SELECT Product.id FROM [complicated sql]');
$ids = Set::extract($tmp, '{n}.0.id');
$products = $this->findAll(array('Product.id' => $ids));
hth
grigri
On May 16, 2:17 pm, Pierre MARCOURT <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I would like to make a MySQL request with an UNION but I can't find out
> a way to do it by using CakePHP methods.
> I looked at Google but it seems that the only way to do it is to make a
> custom request by using /query()/.
> But I don't want to do it that way because I need the recursive option
> that we can have with /find()/ or /findAll()/.
> So, to make it works, I am doing 2 different requests (by using
> /findAll()/) and I merge the 2 results in a array().
> To be honest, I don't like my idea at all.
>
> I would like to know if there is another way to do it better ?
>
> Thanks.
>
> --
> *Pierre MARCOURT*
>
> *IT Department*
> *CableOrganizer.com*
> 5610 NW 12th Ave, suite 214
> Fort Lauderdale, FL 33304
>
> Phone: 954-861-6310
> Fax: 954-861-2001
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---