diff --git a/lib/WebGUI/Crud.pm b/lib/WebGUI/Crud.pm index 3f7094cd3..b85be6124 100644 --- a/lib/WebGUI/Crud.pm +++ b/lib/WebGUI/Crud.pm @@ -599,13 +599,20 @@ Here's an example of this structure: =head4 join -An array reference containing the tables you wish to join together, and the mechanisms to join them. Here's an example. +An array reference containing the tables you wish to join with this one, and the mechanisms to join them. Here's an example. [ - "anotherTable using (someId)", "yetAnotherTable on yetAnotherTable.this = anotherTable.that", ] +=head4 joinUsing + +An array reference of hash references containing the tables you wish to join with this one and the field to use to join. + + [ + {"someTable" => "thisId"}, + ] + =head4 limit Either an integer representing the number of records to return, or an array reference of an integer of the starting record position and another integer representing the number of records to return. @@ -638,6 +645,12 @@ sub getAllSql { # process joins my @joins; + if (exists $options->{joinUsing}) { + foreach my $joint (@{$options->{joinUsing}}) { + my ($table) = keys %{$joint}; + push @joins, " left join ".$dbh->quote_identifier($table)." using (".$dbh->quote_identifier($joint->{$table}).")"; + } + } if (exists $options->{join}) { foreach my $thejoin (@{$options->{join}}) { push @joins, " left join ".$thejoin;