时间:2021-07-01 10:21:17 帮助过:26人阅读
use = ->from('foo' = ->from( TableIdentifier('foo', 'bar' = ->from(('f' => 'foo' = ->from(('f' => TableIdentifier('foo' = ->from('foo')->columns(('bar', 'baz' = ->from('foo')->columns(('bar' => 'baz' = ->from('foo')->columns(('bar' => 'baz', 'bam' = ->from('foo')->columns(('bar' => Expression('COUNT(some_column)' = ->from('foo')->columns(( Expression('COUNT(some_column) AS bar' = ->from('foo')->'(COUNT(?) + ?) AS ?', ('some_column', 5, 'bar'), (Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression:: 5); // // 'SELECT (COUNT("some_column") + \'5\') AS "bar" FROM "foo"'; // joins (plain) = ->from('foo')->('zac', 'm = n' = ->from('foo')->('zac', 'm = n', ('bar', 'baz' = ->from('foo')->('zac', 'm = n', ('bar', 'baz'), Select:: = ->from('foo')->('zac', 'm = n', ('BAR' => 'bar', 'BAZ' => 'baz' = ->from('foo')->(('b' => 'bar'), 'b.foo_id = foo.foo_id' = ->from('foo')->where('x = 5' = ->from('foo')->where(('x = ?' => 5 5); // // 'SELECT "foo".* FROM "foo" WHERE x = \'5\''; // group = ->from('foo')->group(('col1', 'col2' = ->from('foo')->group('col1')->group('col2' = ->from('foo')->group( Expression('DAY(?)', ('col1'), (Expression:: = ->from('foo')->having('x = 5' = ->from('foo')->having(('x = ?' => 5 5); // // 'SELECT "foo".* FROM "foo" HAVING x = \'5\''; // order = ->from('foo')->order('c1' = ->from('foo')->order(('c1', 'c2' = ->from('foo')->order(('c1' => 'DESC', 'c2' => 'Asc')); = ->from('foo')->order(('c1' => 'asc'))->order('c2 desc'); = ->from('foo')->limit(5 5); // // 'SELECT "foo".* FROM "foo" LIMIT \'5\''; // limit with offset = ->from('foo')->limit(5)->offset(10 5, 'offset' => 10); // // 'SELECT "foo".* FROM "foo" LIMIT \'5\' OFFSET \'10\''; // joins with a few keywords in the on clause = ->from('foo')->('zac', '(m = n AND c.x) BETWEEN x AND y.z' = ->from('foo')->order('c1.d2' = ->from('foo')->group('c1.d2'