Method Select::from can accept instance of Select as subselect #2381

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@meniam
meniam commented Sep 18, 2012

No description provided.

@ralphschindler
Member

Your current patch is incomplete.
What exactly is a use case you have, and what would the expected output look like?

Using this kind of test:

$selectsubselect = new Select;
$selectsubselect->from('bar')->where->like('y', '%Foo%');
$select = new Select;
$select->from($selectsubselect);

Will produce SQL that looks like this (which is clearly wrong):

SELECT (SELECT "bar".* FROM "bar" WHERE "y" LIKE ?).* FROM (SELECT "bar".* FROM "bar" WHERE "y" LIKE ?)

This is because there is no alias. If you do this:

$select->from(array('x' => $selectsubselect));

on the other hand, you get this:

SELECT "x".* FROM (SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "x"

which works. That said, can you give me a good use case for not providing an alias with a subselect in from()?

@meniam meniam closed this Sep 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment