Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Zend\Db\Sql\Select Add Support For SubSelect in Join Table - #2881 & #2884 #3606

Merged
merged 1 commit into from

2 participants

@ralphschindler
Collaborator
  • Added support for joining a subselect
  • see #2881 and 2884
@ralphschindler ralphschindler Zend\Db\Sql\Select - #2881
- Added support for joining a subselect
1b53521
@weierophinney weierophinney merged commit 1b53521 into zendframework:develop
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'feature/3606' into develop
Close #3606
Fixes #2881
Fixes #2884
a4d4822
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 29, 2013
  1. @ralphschindler

    Zend\Db\Sql\Select - #2881

    ralphschindler authored
    - Added support for joining a subselect
This page is out of date. Refresh to see the latest.
View
6 library/Zend/Db/Sql/Select.php
@@ -646,7 +646,11 @@ protected function processJoins(PlatformInterface $platform, DriverInterface $dr
$joinName = $joinName->getTableAndSchema();
$joinName = $platform->quoteIdentifier($joinName[1]) . $platform->getIdentifierSeparator() . $platform->quoteIdentifier($joinName[0]);
} else {
- $joinName = $platform->quoteIdentifier($joinName);
+ if ($joinName instanceof Select) {
+ $joinName = '(' . $joinName->processSubSelect($joinName, $platform, $driver, $parameterContainer) . ')';
+ } else {
+ $joinName = $platform->quoteIdentifier($joinName);
+ }
}
$joinSpecArgArray[$j][] = (isset($joinAs)) ? $joinName . ' AS ' . $joinAs : $joinName;
View
12 tests/ZendTest/Db/Sql/SelectTest.php
@@ -950,6 +950,17 @@ public function providerData()
'processJoins' => array(array(array('INNER', '"baz"."bar"', '"m" = "n"')))
);
+ // subselect in join
+ $select39subselect = new Select;
+ $select39subselect->from('bar')->where->like('y', '%Foo%');
+ $select39 = new Select;
+ $select39->from('foo')->join(array('z' => $select39subselect), 'z.foo = bar.id');
+ $sqlPrep39 = 'SELECT "foo".*, "z".* FROM "foo" INNER JOIN (SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "z" ON "z"."foo" = "bar"."id"';
+ $sqlStr39 = 'SELECT "foo".*, "z".* FROM "foo" INNER JOIN (SELECT "bar".* FROM "bar" WHERE "y" LIKE \'%Foo%\') AS "z" ON "z"."foo" = "bar"."id"';
+ $internalTests39 = array(
+ 'processJoins' => array(array(array('INNER', '(SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "z"', '"z"."foo" = "bar"."id"')))
+ );
+
/**
* $select = the select object
* $sqlPrep = the sql as a result of preparation
@@ -999,6 +1010,7 @@ public function providerData()
array($select36, $sqlPrep36, array(), $sqlStr36, $internalTests36, $useNamedParams36),
array($select37, $sqlPrep37, array(), $sqlStr37, $internalTests37),
array($select38, $sqlPrep38, array(), $sqlStr38, $internalTests38),
+ array($select39, $sqlPrep39, array(), $sqlStr39, $internalTests39),
);
}
}
Something went wrong with that request. Please try again.