From long_sam.tw@yahoo.com.tw Fri Jul 10 01:22:56 2026 From: "long_sam.tw" To: koha-devel@lists.koha-community.org Subject: [Koha-devel] koha top query Date: Tue, 27 Feb 2007 18:38:04 +0800 Message-ID: <440079.79975.qm@web72912.mail.tp2.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6879400098382065371==" --===============6879400098382065371== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Koha Top query summary: User query something via hiddin modthod. Keywords will recorded in databases.It will help user when he/ she query catalog. enviroments: koha 2.2.5 & koha 2.2.7 (templete for npl) modfied files:=20 perl scripts - opac-search.pl=E3=80=81opac-main.pl tmpl - opac-main.tmpl database - create Cookie table 1. Cookie table CREATE TABLE `cookie` ( `id` int(255) NOT NULL auto_increment, `names` text NOT NULL, `counts` int(255) NOT NULL default '1', PRIMARY KEY (`id`), KEY `blbnoidx` (`id`) ) ENGINE=3DMyISAM ; 2. opac-search.pl if ($op eq "do_search") { ...... my @tags; ..... # put into cookie =20 for my $count (@value) { my $dbh=3DC4::Context->dbh; $sth =3D $dbh->prepare("insert into cookie(names) values (?)"); $sth->execute($count) || die $sth->errstr; } 3. opac-main.pl my $dbh =3D C4::Context->dbh; my $top=3D"Select names,SUM(counts) \"co\" from cookie group by names order b= y co desc limit 0 , 10"; my $sth=3D$dbh->prepare($top); $sth->execute; =20 my @top; my $top; =20 while (my ($names,$counts) =3D $sth->fetchrow_array) { my %rows =3D ( searchterm =3D> $names, counts =3D> $counts, ); push @top, \%rows; } $sth->finish; $template->param(top =3D> \@top); 4. opac-main.tmpl
.....

# add

Top query keywords=EF=BC=9A "><= /a> =EF=BC=88=EF=BC=89 5. demo site http://lit145.lacc.fju.edu.tw http://koha.nkes.ntct.edu.tw http://koha.jente.edu.tw 6.chinese information http://koha.wikispaces.com/query ___________________________________________________=20 =E6=82=A8=E7=9A=84=E7=94=9F=E6=B4=BB=E5=8D=B3=E6=99=82=E9=80=9A =EF=BC=8D = =E6=BA=9D=E9=80=9A=E3=80=81=E5=A8=9B=E6=A8=82=E3=80=81=E7=94=9F=E6=B4=BB=E3= =80=81=E5=B7=A5=E4=BD=9C=E4=B8=80=E6=AC=A1=E6=90=9E=E5=AE=9A=EF=BC=81=20 http://messenger.yahoo.com.tw/ --===============6879400098382065371==-- From paul.poulain@free.fr Fri Jul 10 01:22:57 2026 From: Paul POULAIN To: koha-devel@lists.koha-community.org Subject: Re: [Koha-devel] koha top query Date: Wed, 07 Mar 2007 17:46:12 +0100 Message-ID: <45EEEC54.50006@free.fr> In-Reply-To: <440079.79975.qm@web72912.mail.tp2.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============9146566835378878786==" --===============9146566835378878786== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit long_sam.tw a écrit : > Koha Top query Hi long_sam, > > summary: > User query something via hiddin modthod. > Keywords will recorded in databases.It will help user when he/ > she query catalog. > > enviroments: > koha 2.2.5 & koha 2.2.7 (templete for npl) > > modfied files: > perl scripts - opac-search.pl、opac-main.pl > tmpl - opac-main.tmpl > database - create Cookie table Nice feature, but I won't add it in official trunk for at least 2 reasons : - it does not use our coding guidelines that says "no SQL query in a .pl script, only in a .pm package". Thus, you should have done a C4/Queries.pm package. - it seems strange to me : you have a counts row in cookie table (I would have choosen another name for this table, but that's a little note), but only store 1 in the row. The best solution, would be to increment the counter row (update ... set counts=counts+1), while you create one every time. You'll get a huge query in the long term... however, I keep the feature in my mind, maybe i'll add it in 3.0 in the future (no promise ;-) ) -- Paul POULAIN et Henri Damien LAURENT Consultants indépendants en logiciels libres et bibliothéconomie (http://www.koha-fr.org) Tel : 04 91 31 45 19 --===============9146566835378878786==--