From: Daniel Westermann-Clark Date: Thu, 27 Jul 2006 05:07:24 +0000 (+0000) Subject: FAQ update: Minor correction from Richard Jolly, mention search_rs, wrap lines, and... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e147365d7612e124e03926dca25e870aad1f0d5e;p=dbsrgits%2FDBIx-Class-Historic.git FAQ update: Minor correction from Richard Jolly, mention search_rs, wrap lines, and minor grammar corrections --- diff --git a/lib/DBIx/Class/Manual/FAQ.pod b/lib/DBIx/Class/Manual/FAQ.pod index 392781e..30e856b 100644 --- a/lib/DBIx/Class/Manual/FAQ.pod +++ b/lib/DBIx/Class/Manual/FAQ.pod @@ -21,8 +21,8 @@ How Do I: =item .. create a database to use? First, choose a database. For testing/experimenting, we reccommend -L, which is a self-contained small database. (i.e. all -you need to do is to install the DBD from CPAN, and it's usable). +L, which is a self-contained small database (i.e. all you +need to do is to install L from CPAN, and it's usable). Next, spend some time defining which data you need to store, and how it relates to the other data you have. For some help on normalisation, @@ -40,16 +40,16 @@ manually, and the one on creating tables from your schema. =item .. use DBIx::Class with L? -Install L from CPAN. See it's +Install L from CPAN. See its documentation, or below, for further details. =item .. set up my DBIx::Class classes automatically from my database? -Install L from CPAN, and read it's documentation. +Install L from CPAN, and read its documentation. =item .. set up my DBIx::Class classes manually? -Look at the L, come back here if you get lost. +Look at the L and come back here if you get lost. =item .. create my database tables from my DBIx::Class schema? @@ -77,23 +77,30 @@ lot later. =item .. tell DBIx::Class about relationships between my tables? -There are a vareity of relationship types that come pre-defined for you to use. These are all listed in L. If you need a non-standard type, or more information, look in L. +There are a vareity of relationship types that come pre-defined for +you to use. These are all listed in L. If +you need a non-standard type, or more information, look in +L. =item .. define a one-to-many relationship? -This is called a C relationship on the one side, and a C relationship on the many side. Currently these need to be set up individually on each side. See L for details. +This is called a C relationship on the one side, and a +C relationship on the many side. Currently these need to +be set up individually on each side. See L +for details. =item .. define a relationship where this table contains another table's primary key? (foreign key) -Create a C relationship for the field containing the foreign key. L. +Create a C relationship for the field containing the +foreign key. See L. =item .. define a foreign key relationship where the key field may contain NULL? -Just create a C relationship, as above. If -the column is NULL then the inflation to the foreign object will not -happen. This has a side effect of not always fetching all the relevant -data, if you use a nullable foreign-key relationship in a JOIN, then -you probably want to set the join_type to 'left'. +Just create a C relationship, as above. If the column is +NULL then the inflation to the foreign object will not happen. This +has a side effect of not always fetching all the relevant data, if you +use a nullable foreign-key relationship in a JOIN, then you probably +want to set the C to C. =item .. define a relationship where the key consists of more than one column? @@ -110,12 +117,13 @@ Read the documentation on L. By default, DBIx::Class cascades deletes and updates across C relationships. If your database already does this (and -probably better), turn it off by supplying C<< cascade_delete => 0 >> in -the relationship attributes. See L. +that is probably better), turn it off by supplying C<< cascade_delete => 0 >> +in the relationship attributes. See L. =item .. use a relationship? -Use it's name. An accessor is created using the name. See examples in L. +Use its name. An accessor is created using the name. See examples in +L. =back @@ -126,9 +134,8 @@ Use it's name. An accessor is created using the name. See examples in L object, as mentioned above in ".. connect to my -database". Find the -L that you want -to search in, and call C on it. See +database". Find the L +that you want to search in, and call C on it. See L. =item .. search using database functions? @@ -146,15 +153,16 @@ so: =item .. sort the results of my search? -Supply a list of columns you want to sort by, to the C -attribute, see L. +Supply a list of columns you want to sort by to the C +attribute. See L. =item .. sort my results based on fields I've aliased using C? You don't. You'll need to supply the same functions/expressions to -C, as you did to C. -To get "fieldname AS alias" in your SQL, you'll need to supply a literal chunk of SQL in your C attribute, such as: ->search({}, { select => [ \'now() AS currenttime'] }) @@ -207,8 +215,8 @@ for the join used by each relationship. Currently, L can only create join conditions using equality, so you're probably better off creating a C in your -database, and using that as your source. A C is a stored SQL query, -which can be accessed similarly to a table, see your database +database, and using that as your source. A C is a stored SQL +query, which can be accessed similarly to a table, see your database documentation for details. =item .. search using greater-than or less-than and database functions? @@ -227,7 +235,7 @@ and not: =item .. find more help on constructing searches? Behind the scenes, DBIx::Class uses L to help construct -it's SQL searches. So if you fail to find help in the +its SQL searches. So if you fail to find help in the L, try looking in the SQL::Abstract documentation. @@ -294,10 +302,12 @@ You can add your own data accessors to your classes. =item How do I use DBIx::Class objects in my TT templates? -Like normal objects, mostly. However you need to watch out for TTs -calling methods in list context, this means that when calling -relationship accessors you will not get resultsets, but a list of all -the related objects. +Like normal objects, mostly. However you need to watch out for TT +calling methods in list context. When calling relationship accessors +you will not get resultsets, but a list of all the related objects. + +Starting with version 0.07, you can use L +to work around this issue. =item See the SQL statements my code is producing? @@ -311,6 +321,6 @@ L runs the actual SQL statement as late as possible, thus if you create a resultset using C in scalar context, no query is executed. You can create further resultset refinements by calling search again or relationship accessors. The SQL query is only run when -you ask the resultset for an actual Row object. +you ask the resultset for an actual row object. =back