File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -33,11 +33,20 @@ $mysql->getAliasRegistry()->add('t', 'testdb.test__');
33
33
### Select
34
34
35
35
``` PHP
36
- $select = $mysql->select(['customer_count' => 'COUNT(*)'])
37
- ->from('t1', 't#test1') // You are forced to used aliases for tables.
36
+ $subSelect = function ($id) use ($mysql) {
37
+ return $mysql->select()
38
+ ->field('t.id')
39
+ ->from('t', 'table')
40
+ ->where('t.foreign_id=?', $id);
41
+ };
42
+
43
+ $select = $mysql->select()
44
+ ->field('COUNT(*)', 'customer_count')
45
+ ->from('t1', 't#test1')
38
46
->joinInner('t2', 't#test2', 't2.test_id = t1.id AND t2.field1 = ?', 123)
39
47
->joinLeft('t3', 't#test3', 't3.test_id = t1.id')
40
48
->joinRight('t4', 't#test4', 't4.test_id = t1.id')
49
+ ->joinRight('t5', $subSelect(10), 't5.test_id = t1.id')
41
50
->orderBy('t1.field1')
42
51
->orderBy('t1.field2', 'DESC')
43
52
->limit(100)
You can’t perform that action at this time.
0 commit comments