Bug 12721: (followup) Replace mysqlism by DBIx::Class
authorMarc Véron <veron@veron.ch>
Wed, 27 Apr 2016 10:38:58 +0000 (12:38 +0200)
committerChris Cormack <chrisc@catalyst.net.nz>
Sun, 19 Jun 2016 21:23:22 +0000 (09:23 +1200)
This patch removes the mysqlism (see comment #18)

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Fixed QA tools complaints about missing lines before
and after =cut in POD.

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
(cherry picked from commit ef97b6b301a5c1a9ef5c63cc93933bf7442513fc)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
(cherry picked from commit 8fb9837adeecce2896085d9f3d463633a2cbb8ae)
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

C4/Members/Statistics.pm

index c491819..b8b3a0f 100644 (file)
@@ -48,8 +48,8 @@ our $fields = get_fields();
   Get fields form syspref 'StatisticsFields'
   Returns list of valid fields, defaults to 'location|itype|ccode'
   if syspref is empty or does not contain valid fields
-=cut
 
+=cut
 
 sub get_fields {
 
@@ -59,14 +59,11 @@ sub get_fields {
     if ( $syspref ) {
         my @ret;
         my @spfields = split ('\|', $syspref);
-        my $dbh=C4::Context->dbh;
-        my $sth = $dbh->prepare('SHOW COLUMNS FROM items');
-        $sth->execute;
-        my $dbfields =  $sth->fetchall_hashref('Field');
-        $sth->finish();
+        my $schema       = Koha::Database->new()->schema();
+        my @columns = $schema->source('Item')->columns;
 
         foreach my $fn ( @spfields ) {
-            push ( @ret, $fn ) if ( $dbfields->{ $fn } );
+            push ( @ret, $fn ) if ( grep(/^$fn$/, @columns) );
         }
         $ret = join( '|', @ret);
     }
@@ -76,7 +73,9 @@ sub get_fields {
 =head2 construct_query
   Build a sql query from a subquery
   Adds statistics fields to the select and the group by clause
+
 =cut
+
 sub construct_query {
     my $count    = shift;
     my $subquery = shift;
@@ -95,7 +94,9 @@ sub construct_query {
 
 =head2 GetTotalIssuesTodayByBorrower
   Return total issues for a borrower at this current day
+
 =cut
+
 sub GetTotalIssuesTodayByBorrower {
     my ($borrowernumber) = @_;
     my $dbh   = C4::Context->dbh;
@@ -114,7 +115,9 @@ sub GetTotalIssuesTodayByBorrower {
 
 =head2 GetTotalIssuesReturnedTodayByBorrower
   Return total issues returned by a borrower at this current day
+
 =cut
+
 sub GetTotalIssuesReturnedTodayByBorrower {
     my ($borrowernumber) = @_;
     my $dbh   = C4::Context->dbh;
@@ -128,7 +131,9 @@ sub GetTotalIssuesReturnedTodayByBorrower {
 
 =head2 GetPrecedentStateByBorrower
   Return the precedent state (before today) for a borrower of his checkins and checkouts
+
 =cut
+
 sub GetPrecedentStateByBorrower {
     my ($borrowernumber) = @_;
     my $dbh   = C4::Context->dbh;