Skip to content

Commit

Permalink
split examples into two sections
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 28, 2018
1 parent 8112c33 commit d07e318
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/Mojo/Pg/Database.pm
Expand Up @@ -502,15 +502,20 @@ L<SQL::Abstract>.
As well as some PostgreSQL specific extensions added by L<SQL::Abstract::Pg>.
# "select foo as bar from some_table"
$db->select('some_table', [[foo => 'bar']]);
# "select * from foo join bar on (bar.foo_id = foo.id)"
$db->select(['foo', ['bar', foo_id => 'id']]);
# "select * from foo left join bar on (bar.foo_id = foo.id)"
$db->select(['foo', [-left => 'bar', foo_id => 'id']]);
# "select foo as bar from some_table"
$db->select('some_table', [[foo => 'bar']]);
# "select extract(epoch from foo) as foo, bar from some_table"
$db->select('some_table', [\'extract(epoch from foo) as foo', 'bar']);
Including a new last argument to pass many new options.
# "select * from some_table where foo = 'bar' order by id desc"
$db->select('some_table', '*', {foo => 'bar'}, {order_by => {-desc => 'id'}});
Expand All @@ -529,9 +534,6 @@ As well as some PostgreSQL specific extensions added by L<SQL::Abstract::Pg>.
# "select * from some_table where id = 1 for update skip locked"
$db->select('some_table', '*', {id => 1}, {for => \'update skip locked'});
# "select extract(epoch from foo) as foo, bar from some_table"
$db->select('some_table', [\'extract(epoch from foo) as foo', 'bar']);
=head2 select_p
my $promise = $db->select_p($source, $fields, $where, \%options);
Expand Down

0 comments on commit d07e318

Please sign in to comment.