annotate select * from itemtypes with -- sql comment
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 2 Apr 2012 19:17:45 +0000 (21:17 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 30 May 2012 20:28:11 +0000 (22:28 +0200)
This allows to see SQL queries in DBI Profile plack panel

I checked, DBI::Profile doesn't have notion on where query
came from other than filename, because it would be great to
have source file and line number automatically, but we
don't have it (yet :-)

C4/ItemType.pm
C4/Koha.pm
C4/Search.pm

index 648cff9..4c66891 100644 (file)
@@ -79,7 +79,7 @@ sub all {
 
     my @itypes;
     for ( @{$dbh->selectall_arrayref(
-        "SELECT * FROM itemtypes ORDER BY description", { Slice => {} })} )
+        "SELECT * FROM itemtypes ORDER BY description -- C4::ItemType", { Slice => {} })} )
     {
         utf8::encode($_->{description});
         push @itypes, $class->new($_);
index 81c5859..f5a4db3 100644 (file)
@@ -247,7 +247,7 @@ sub GetItemTypes {
     my $dbh   = C4::Context->dbh;
     my $query = qq|
         SELECT *
-        FROM   itemtypes
+        FROM   itemtypes -- memoize
     |;
     my $sth = $dbh->prepare($query);
     $sth->execute;
@@ -418,7 +418,7 @@ sub getframeworkinfo {
     my ($frameworkcode) = @_;
     my $dbh             = C4::Context->dbh;
     my $sth             =
-      $dbh->prepare("select * from biblio_framework where frameworkcode=?");
+      $dbh->prepare("select * from biblio_framework where frameworkcode=? -- getframeworkinfo");
     $sth->execute($frameworkcode);
     my $res = $sth->fetchrow_hashref;
     return $res;
@@ -435,7 +435,7 @@ Returns information about an itemtype.
 sub getitemtypeinfo {
     my ($itemtype) = @_;
     my $dbh        = C4::Context->dbh;
-    my $sth        = $dbh->prepare("select * from itemtypes where itemtype=?");
+    my $sth        = $dbh->prepare("select * from itemtypes where itemtype=? -- getitemtypeinfo");
     $sth->execute($itemtype);
     my $res = $sth->fetchrow_hashref;
 
index a301b79..a2ad6fd 100644 (file)
@@ -1447,7 +1447,7 @@ sub searchResults {
     my %itemtypes;
     $bsth =
       $dbh->prepare(
-        "SELECT itemtype,description,imageurl,summary,notforloan FROM itemtypes"
+        "SELECT itemtype,description,imageurl,summary,notforloan FROM itemtypes -- C4::Search"
       );
     $bsth->execute();
     while ( my $bdata = $bsth->fetchrow_hashref ) {