X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FManual%2FCookbook.pod;h=c84df814b71dc0d910916e61470b1f28954418a3;hb=48580715af3072905f2c71dc27e7f70f21a11338;hp=7ae3630e59c6bf93957c70d06680da7345523fee;hpb=83677d0711ff901937ed402079dad9e9604e2dc5;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 7ae3630..c84df81 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -141,7 +141,7 @@ Next, you can execute your complex query using bind parameters like this: ); ... and you'll get back a perfect L (except, of course, -that you cannot modify the rows it contains, ie. cannot call L, +that you cannot modify the rows it contains, e.g. cannot call L, L, ... on it). Note that you cannot have bind parameters unless is_virtual is set to true. @@ -201,7 +201,7 @@ to access the returned value: # SELECT name name, LENGTH( name ) # FROM artist -Note that the C attribute B with the sql +Note that the C attribute B with the SQL syntax C< SELECT foo AS bar > (see the documentation in L). You can control the C part of the generated SQL via the C<-as> field attribute as follows: @@ -317,7 +317,7 @@ 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 >). -=head2 Subqueries (EXPERIMENTAL) +=head2 Subqueries You can write subqueries relatively easily in DBIC. @@ -329,7 +329,7 @@ You can write subqueries relatively easily in DBIC. artist_id => { 'IN' => $inside_rs->get_column('id')->as_query }, }); -The usual operators ( =, !=, IN, NOT IN, etc) are supported. +The usual operators ( =, !=, IN, NOT IN, etc.) are supported. B: You have to explicitly use '=' when doing an equality comparison. The following will B work: @@ -365,10 +365,6 @@ That creates the following SQL: WHERE artist_id = me.artist_id ) -=head3 EXPERIMENTAL - -Please note that subqueries are considered an experimental feature. - =head2 Predefined searches You can write your own L class by inheriting from it @@ -415,7 +411,7 @@ Then call your new method in your code: Using SQL functions on the left hand side of a comparison is generally not a good idea since it requires a scan of the entire table. (Unless your RDBMS -supports indexes on expressions - including return values of functions -, and +supports indexes on expressions - including return values of functions - and you create an index on the return value of the function in question.) However, it can be accomplished with C when necessary. @@ -775,7 +771,7 @@ B package My::App::Schema; - use base DBIx::Class::Schema; + use base 'DBIx::Class::Schema'; # load subclassed classes from My::App::Schema::Result/ResultSet __PACKAGE__->load_namespaces; @@ -795,7 +791,7 @@ B use strict; use warnings; - use base My::Shared::Model::Result::Baz; + use base 'My::Shared::Model::Result::Baz'; # WARNING: Make sure you call table() again in your subclass, # otherwise DBIx::Class::ResultSourceProxy::Table will not be called @@ -818,7 +814,7 @@ this example we have a single user table that carries a boolean bit for admin. We would like like to give the admin users objects (L) the same methods as a regular user but also special admin only methods. It doesn't make sense to create two -seperate proxy-class files for this. We would be copying all the user +separate proxy-class files for this. We would be copying all the user methods into the Admin class. There is a cleaner way to accomplish this. @@ -1272,7 +1268,7 @@ row. my $schema = MySchema->connect("dbi:Pg:dbname=my_db"); # Start a transaction. Every database change from here on will only be - # commited into the database if the eval block succeeds. + # committed into the database if the eval block succeeds. eval { $schema->txn_do(sub { # SQL: BEGIN WORK; @@ -1325,7 +1321,7 @@ row. }; if ($@) { # There was an error while handling the $job. Rollback all changes - # since the transaction started, including the already commited + # since the transaction started, including the already committed # ('released') savepoints. There will be neither a new $job nor any # $thing entry in the database. @@ -1625,10 +1621,10 @@ B Add the L schema component to your Schema class. This will add a new table to your database called C which will keep track of which version is installed -and warn if the user trys to run a newer schema version than the +and warn if the user tries to run a newer schema version than the database thinks it has. -Alternatively, you can send the conversion sql scripts to your +Alternatively, you can send the conversion SQL scripts to your customers as above. =head2 Setting quoting for the generated SQL @@ -1710,7 +1706,7 @@ methods: } ); -In conditions (eg. C<\%cond> in the L family of +In conditions (e.g. C<\%cond> in the L family of methods) you cannot directly use array references (since this is interpreted as a list of values to be Ced), but you can use the following syntax to force passing them as bind values: