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__');
3333### Select
3434
3535``` 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')
3846->joinInner('t2', 't#test2', 't2.test_id = t1.id AND t2.field1 = ?', 123)
3947->joinLeft('t3', 't#test3', 't3.test_id = t1.id')
4048->joinRight('t4', 't#test4', 't4.test_id = t1.id')
49+ ->joinRight('t5', $subSelect(10), 't5.test_id = t1.id')
4150->orderBy('t1.field1')
4251->orderBy('t1.field2', 'DESC')
4352->limit(100)
You can’t perform that action at this time.
0 commit comments