NAME

SPOPS::Manual::Cookbook - Recipes for SPOPS usage

DESCRIPTION

This is a collection of recipes for usage of SPOPS. Some are common, some might be esoteric, but all of them should help to illuminate how SPOPS works and ways that you can expand it for your own needs.

DATASOURCE AVAILABILITY

SPOPS implementations that rely on some sort of datasource connection need to make that connection available all objects and class methods that need it. You can also pass a connection around to all calls, but this becomes difficult to maintain and is generally only used for special cases.

All implementations use the method global_datasource_handle() to retrieve the needed connection. So if you make the connection available via this method you never have to pass around handles or even worry about it.

There are generally two ways (which are basically the same) to do this:

Make the handle available via a method in the SPOPS object class itself.

Make the handle available via a method in the ancestor class.

Both are demonstrated below, using the SPOPS::DBI implementation as an example.

Datasource via object class

This method works well if you have a small number of objects, or if you want to something quickly.

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.