forked from envms/fluentpdo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sub-select in SELECT clause (without aliases and smart join)
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--TEST-- | ||
Simple sub-select | ||
--FILE-- | ||
<?php | ||
include_once dirname(__FILE__) . "/connect.inc.php"; | ||
/* @var $fpdo FluentPDO */ | ||
|
||
$subquery = $fpdo->from('article')->select(null)->select('COUNT(id)')->where('user_id', new FluentLiteral('user.id')); | ||
|
||
$query = $fpdo->from('user')->select($subquery)->where('id', 1); | ||
|
||
echo $query->getQuery() . "\n\n"; | ||
print_r($query->getParameters()) . "\n"; | ||
|
||
?> | ||
--EXPECTF-- | ||
SELECT user.*, (SELECT COUNT(id) | ||
FROM article | ||
WHERE user_id = ?) | ||
FROM user | ||
WHERE id = ? | ||
|
||
Array | ||
( | ||
[0] => FluentLiteral Object | ||
( | ||
[value:protected] => user.id | ||
) | ||
|
||
[1] => 1 | ||
) |