From: Kieren Diment Date: Wed, 14 Feb 2007 10:05:51 +0000 (+0000) Subject: pointed out ambiguity of as attribs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d676881ffc63beab0cb32de5082c32b89705a468;p=dbsrgits%2FDBIx-Class-Historic.git pointed out ambiguity of as attribs --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index dfb1f57..e95a95c 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -110,9 +110,12 @@ to access the returned value: # SELECT name name, LENGTH( name ) # FROM artist -If your alias exists as a column in your base class (i.e. it was added -with C), you just access it as normal. Our C -class has a C column, so we just use the C accessor: +Note that the C< as > attribute has absolutely nothing to with the sql +syntax C< SELECT foo AS bar > (see the documentation in +L). If your alias exists as a +column in your base class (i.e. it was added with C), you +just access it as normal. Our C class has a C column, so +we just use the C accessor: my $artist = $rs->first(); my $name = $artist->name(); @@ -139,7 +142,7 @@ any of your aliases using either of these: select => [ { distinct => [ $source->columns ] } ], - as => [ $source->columns ] + as => [ $source->columns ] # remember 'as' is not the same as SQL AS :-) } ); @@ -176,6 +179,10 @@ L supports C as follows: # LEFT JOIN cd cds ON ( cds.artist = me.artistid ) # GROUP BY name +Please see L documentation if you +are in any way unsure about the use of the attributes above (C< join +>, C< select >, C< as > and C< group_by >). + =head3 Predefined searches You can write your own L class by inheriting from it @@ -415,7 +422,7 @@ ways, the obvious one is to use search: {}, { select => [ { sum => 'Cost' } ], - as => [ 'total_cost' ], + as => [ 'total_cost' ], # remember this 'as' is for DBIx::Class::ResultSet not SQL } ); my $tc = $rs->first->get_column('total_cost');