X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FOrdered.pm;h=737477df15402c146d9d01883679579256cb3852;hb=79a77af646d55bab4840d883527d4f73c9426427;hp=88e1110ea32896bec0e92ec93fc96f3df7d0df61;hpb=90545b68b06c2d2d288d593462539fe45fff48a6;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Ordered.pm b/lib/DBIx/Class/Ordered.pm index 88e1110..737477d 100644 --- a/lib/DBIx/Class/Ordered.pm +++ b/lib/DBIx/Class/Ordered.pm @@ -18,6 +18,26 @@ Create a table for your ordered data. position INTEGER NOT NULL ); +Optionally, add one or more columns to specify groupings, allowing you +to maintain independent ordered lists within one table: + + CREATE TABLE items ( + item_id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + position INTEGER NOT NULL, + group_id INTEGER NOT NULL + ); + +Or even + + CREATE TABLE items ( + item_id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + position INTEGER NOT NULL, + group_id INTEGER NOT NULL, + other_group_id INTEGER NOT NULL + ); + In your Schema or DB class add "Ordered" to the top of the component list. @@ -29,6 +49,14 @@ each row. package My::Item; __PACKAGE__->position_column('position'); +If you are using one grouping column, specify it as follows: + + __PACKAGE__->grouping_column('group_id'); + +Or if you have multiple grouping columns: + + __PACKAGE__->grouping_column(['group_id', 'other_group_id']); + That's it, now you can change the position of your objects. #!/use/bin/perl @@ -443,8 +471,8 @@ need to use them. =head2 _grouping_clause -This method returns a name=>value pair for limiting a search -by the collection column. If the collection column is not +This method returns one or more name=>value pairs for limiting a search +by the grouping column(s). If the grouping column is not defined then this will return an empty list. =cut