Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

wants to merge 1 commit into


None yet
2 participants

meniam commented Sep 18, 2012

No description provided.


ralphschindler commented Sep 25, 2012

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;

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