I think that will be too slow. If you fetch 100000 rows, perl function will
be called 100000 times.
If you leave this work for SQL then C function will be called 100000 times
which is much faster.
2007/3/19, rahed <[EMAIL PROTECTED]>:
rahed <[EMAIL PROTECTED]> writes:
> select id,round((julianday(date2) - julianday(date1))*86400) as 'tdiff'
> from mytable;
I proceeded and created a private SQLite function myfunc.
my $dbh = $c->model('MyModelDB')->storage->dbh;
$dbh->func('myfunc',2,\&subtract,'create_function');
sub subtract {
my (
$difference,
$end,
$start,
);
($end,$start) = @_;
$difference = ($end-$start)*86400;
return $difference;
}
And in the search
select => {round=>{myfunc=>[{'julianday'=>'t_end_diag'},
{'julianday'=>'t_start_diag'},
],
};
This produces the required select. Can I go without a private function?
--
Radek
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive:
http://www.mail-archive.com/[email protected]/
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/