Re: Classic unions
| From: | Justin Patrin | Date: | Sun, 15 May 2005 16:29:15 +0000 |
| Subject: | Re: Classic unions | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19229@lists.php.net to get a copy of this message | ||
On 5/14/05, Adriano de Oliveira Gonçalves <adriano.php@globo.com> wrote:
> Hello,
> I would like to know if the DB_DataObject supports to create querys with classic unions, as
> this below:
This is not a union, it's a join. Unions take the results from two
queries and merge them.
>
> SELECT
> tipos_processos.NOME AS 'ID_TIPO_PROCESSO',
> clientes.NOME AS 'ID_CLIENTE',
> STATUS,
> usuarios.username AS 'USUARIO_CRIADOR'
> FROM
> processos,
> usuarios,
> tipos_processos,
> clientes
> WHERE
> processos.ID_TIPO_PROCESSO=tipos_processos.ID
> AND processos.ID_CLIENTE=clientes.ID
> AND processos.USUARIO_CRIADOR=usuarios.USERNAME
>
> In this case, the method joinAdd not cause the same effect. I arrived to try to mount thus:
>
> $do->joinAdd(DB_DataObject::factory("tipos_processos"));
> $do->joinAdd(DB_DataObject::factory("clientes"));
> $do->joinAdd(DB_DataObject::factory("usuarios"));
> $do->selectAdd("tipos_processos.NOME AS 'ID_TIPO_PROCESSO'");
> $do->selectAdd("clientes.NOME AS 'ID_CLIENTE'");
> $do->selectAdd("usuarios.username AS 'USUARIO_CRIADOR'");
>
Why exactly are you trying to do this? I believe DB_DataObject
supports this, but it depends on the DB type. I believe it does this
for Oracle.
--
Justin Patrin