08-19-2001
9 More Discussions You Might Find Interesting
1. UNIX Desktop Questions & Answers
does anyone know of a course for unix beginners (1 Reply)
Discussion started by: moose
1 Replies
2. UNIX Desktop Questions & Answers
I am new to non Windows operating systems. Does anyone have advice on which UNIX OS vendor would be good for learning purposes. I was looking for a version of UNIX that runs on the Intel platform. Do you have any recommendations on where to purchase the software? Thank you. (14 Replies)
Discussion started by: jmy113437
14 Replies
3. Shell Programming and Scripting
Hi ,
I am new to shell scripting . I have been go through many sites and ready the material for shell scripting. But I am not getting complete examples for practice.
Can any one suggest me any site that contains lots of ready examples for shell scripting ??
Regards (0 Replies)
Discussion started by: himvat
0 Replies
4. Programming
Hi everyone:
I'm developing a dynamic library for notifications, this library is used for a daemon that i've programmed, when something goes wrong the library should send an email to an administrator, but since sending an email is a non-vital process then it can fail (it should work as an... (4 Replies)
Discussion started by: edgarvm
4 Replies
5. Shell Programming and Scripting
hi,
i start using awk and have a very basic problem. here's my code:
#! /usr/bin/awk -f
# 2010, scz
#
{
$1 == "test" { print $2 }
}
this works on the command line but not as "program" - what is the difference between awk programs on the command line and executing awk... (3 Replies)
Discussion started by: svencz
3 Replies
6. UNIX Desktop Questions & Answers
1. I would like to know which UNIX version I should use as a beginner and from I can get it?
2. How much hard disk space(drive space...in case of dual boot) does it require?
3. Can I run it from USB or Live CD?
4. Is there any need of installing UNIX if I have Linux... ie does Linux... (3 Replies)
Discussion started by: ArpitRaj
3 Replies
7. Shell Programming and Scripting
Hey, i hope someone can help me with this program.
I need to write a program in shell which will return how many times and how much time have users been logged in system between two dates. We give time as 2 dates as arguments in command line.
Example:
$ nameofprogram 27/04 06/05
... (1 Reply)
Discussion started by: Exander
1 Replies
8. UNIX for Dummies Questions & Answers
i'm just a beginner in unix environment- please help which book to read and which os to use!!! :confused: seriously i've no idea what is unix or how much capable it is!! (1 Reply)
Discussion started by: gaurav singh
1 Replies
9. UNIX for Beginners Questions & Answers
Hello!
I need some advices from You. How many days i need to setup cluster using virtual box for mid exp user? Do you have any ideas related to master thesis related to clustering? I need to include some search aspect within that topic.Can You recommend some books/docs about that case?
Thank... (4 Replies)
Discussion started by: protos27
4 Replies
LEARN ABOUT DEBIAN
dbix::class::helper::resultset::correlaterelationship
DBIx::Class::Helper::ResultSet::CorrelateRelationship(3pUser Contributed Perl DocumentatDBIx::Class::Helper::ResultSet::CorrelateRelationship(3pm)
NAME
DBIx::Class::Helper::ResultSet::CorrelateRelationship - Easily correlate your ResultSets
VERSION
version 2.013002
SYNOPSIS
package MyApp::Schema::ResultSet::Author;
use base 'DBIx::Class::ResultSet';
__PACKAGE__->load_components(qw(Helper::ResultSet::CorrelateRelationship));
sub with_book_count {
my $self = shift;
$self->search(undef, {
'+columns' => {
book_count => $self->correlate('book')->count_rs->as_query
}
});
}
1;
And then elsewhere, like in a controller:
my $rows = $schema->resultset('Author')->with_book_count->all;
DESCRIPTION
Correlated queries are one of the coolest things I've learned about for SQL since my initial learning of SQL. Unfortunately they are
somewhat confusing. DBIx::Class has supported doing them for a long time, but generally people don't think of them because they are so
rare. I won't go through all the details of how they work and cool things you can do with them, but here are a couple high level things
you can use them for to save you time or effort.
If you want to select a list of authors and counts of books for each author, you could use "group_by" and something like "COUNT(book.id)",
but then you'd need to make your select list match your "group_by" and it would just be a hassle forever after that. The "SYNOPSIS" is a
perfect example of how to implement this.
If you want to select a list of authors and two separate kinds of counts of books for each author, as far as I know, you must use a
correlated subquery in DBIx::Class. Here is an example of how you might do that:
package MyApp::Schema::ResultSet::Author;
use base 'DBIx::Class::ResultSet';
__PACKAGE__->load_components(qw(Helper::ResultSet::CorrelateRelationship));
sub with_good_book_count {
my $self = shift;
$self->search(undef, {
'+columns' => {
good_book_count => $self->correlate('books')->good->count_rs->as_query
}
});
}
sub with_bad_book_count {
my $self = shift;
$self->search(undef, {
'+columns' => {
bad_book_count => $self->correlate('books')->bad->count_rs->as_query
}
});
}
1;
And then elsewhere, like in a controller:
my $rows = $schema->resultset('Author')
->with_bad_book_count
->with_good_book_count
->all;
This assumes that the Book resultset has "good" and "bad" methods.
See "NOTE" in DBIx::Class::Helper::ResultSet for a nice way to apply it to your entire schema.
METHODS
correlate
$rs->correlate($relationship_name)
Correlate takes a single argument, a relationship for the invocant, and returns a resultset that can be used in the selector list.
AUTHOR
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.14.2 2012-06-18 DBIx::Class::Helper::ResultSet::CorrelateRelationship(3pm)