Table of Contents
Koha currently stores all data in a MySQL database called "Koha." The Koha code expects the MySQL password hashing used in versions of MySQL before 4.1; if you are using MySQL 4.1, you should run your mysql daemon with the "--old-passwords" option. (Note that you may not need to do this if you are using Apache 2.0 or later.) MySQL 5.0 and later will not currently work with Koha because of a conflict between MySQL reserved words and Koha column names.
If the use of a table or column is not apparent from its name, and you have a basic knowledge of Perl, you can use grep to search for the name in the Koha code. For example, if you want to know how the table sessions is used, try:
[koha@localhost ~]$ grep -R 'sessions' /usr/local/koha/intranet/
/usr/local/koha/intranet/modules/C4/Auth.pm: "SELECT userid,ip,lasttime FROM sessions WHERE sessionid=?",
/usr/local/koha/intranet/modules/C4/Auth.pm: $dbh->do("DELETE FROM sessions WHERE sessionID=?", undef, $sessionID);
/usr/local/koha/intranet/modules/C4/Auth.pm: $dbh->do("DELETE FROM sessions WHERE sessionID=?", undef, $sessionID);
/usr/local/koha/intranet/modules/C4/Auth.pm: $dbh->do("DELETE FROM sessions WHERE sessionID=?", undef, $sessionID);
/usr/local/koha/intranet/modules/C4/Auth.pm: $dbh->do("UPDATE sessions SET lasttime=? WHERE sessionID=?",
/usr/local/koha/intranet/modules/C4/Auth.pm: $dbh->do("DELETE FROM sessions WHERE sessionID=? AND userid=?",
/usr/local/koha/intranet/modules/C4/Auth.pm: $dbh->do("INSERT INTO sessions (sessionID, userid, ip,lasttime) VALUES (?, ?, ?, ?)",
/usr/local/koha/intranet/modules/C4/Auth_with_ldap.pm: "SELECT userid,ip,lasttime FROM sessions WHERE sessionid=?",
/usr/local/koha/intranet/modules/C4/Auth_with_ldap.pm: $dbh->do("DELETE FROM sessions WHERE sessionID=?", undef, $sessionID);
/usr/local/koha/intranet/modules/C4/Auth_with_ldap.pm: $dbh->do("DELETE FROM sessions WHERE sessionID=?", undef, $sessionID);
/usr/local/koha/intranet/modules/C4/Auth_with_ldap.pm: $dbh->do("DELETE FROM sessions WHERE sessionID=?", undef, $sessionID);
/usr/local/koha/intranet/modules/C4/Auth_with_ldap.pm: $dbh->do("UPDATE sessions SET lasttime=? WHERE sessionID=?",
/usr/local/koha/intranet/modules/C4/Auth_with_ldap.pm: $dbh->do("DELETE FROM sessions WHERE sessionID=? AND userid=?",
/usr/local/koha/intranet/modules/C4/Auth_with_ldap.pm: $dbh->do("INSERT INTO sessions (sessionID, userid, ip,lasttime) VALUES (?, ?, ?, ?)",
/usr/local/koha/intranet/scripts/updater/updatedatabase: sessions => "( sessionID varchar(255) NOT NULL default '',
/usr/local/koha/intranet/cgi-bin/logout.pl:my $sessions;
/usr/local/koha/intranet/cgi-bin/logout.pl:open (S, "/tmp/sessions");
/usr/local/koha/intranet/cgi-bin/logout.pl: $sessions->{$sid}->{'userid'}=$u;
/usr/local/koha/intranet/cgi-bin/logout.pl: $sessions->{$sid}->{'lasttime'}=$lasttime;
/usr/local/koha/intranet/cgi-bin/logout.pl:open (S, ">/tmp/sessions");
/usr/local/koha/intranet/cgi-bin/logout.pl:foreach (keys %$sessions) {
/usr/local/koha/intranet/cgi-bin/logout.pl: my $userid=$sessions->{$_}->{'userid'};
/usr/local/koha/intranet/cgi-bin/logout.pl: my $lasttime=$sessions->{$_}->{'lasttime'};
/usr/local/koha/intranet/cgi-bin/logout.pl:my $sth=$dbh->prepare("select userid,ip from sessions where sessionID=?");
/usr/local/koha/intranet/cgi-bin/logout.pl:$sth=$dbh->prepare("delete from sessions where sessionID=?");If you want to reduce the amount of information returned, you can limit grep to looking in /usr/local/koha/intranet/modules/C4: the most useful information is likely to be found in these Koha modules. Most of the modules also have documentation that can be accessed using perldoc:
[koha@localhost ~]$ perldoc /usr/local/koha/intranet/modules/C4/Auth.pm
NAME
C4::Auth - Authenticates Koha users
SYNOPSIS
use CGI;
use C4::Auth;
my $query = new CGI;
my ($template, $borrowernumber, $cookie)
= get_template_and_user({template_name => "opac-main.tmpl",
query => $query,
type => "opac",
authnotrequired => 1,
flagsrequired => {borrow => 1},
});
print $query->header(
-type => guesstype($template->output),
-cookie => $cookie
), $template->output;
DESCRIPTION
The main function of this module is to provide
authentification.
[snip]
checkauth
($userid, $cookie, $sessionID) = &checkauth($query, $noauth, $flagsrequired, $type);
Verifies that the user is authorized to run this script. If the user is authorized, a (userid, cookie, session-id, flags) quadruple
is returned. If the user is not authorized but does not have the required privilege (see $flagsrequired below), it displays an
error page and exits. Otherwise, it displays the login page and exits.You should now have a pretty good idea of how the sessions table is used by Koha.
Here is the database structure of Koha 2.2.4:
SHOW TABLES; +-------------------------+ | Tables_in_Koha | +-------------------------+ | accountlines | | accountoffsets | | additionalauthors | | aqbasket | | aqbookfund | | aqbooksellers | | aqbudget | | aqorderbreakdown | | aqorderdelivery | | aqorders | | auth_header | | auth_subfield_structure | | auth_subfield_table | | auth_tag_structure | | auth_types | | auth_word | | authorised_values | | biblio | | biblio_framework | | biblioanalysis | | biblioitems | | bibliosubject | | bibliosubtitle | | bibliothesaurus | | bookshelf | | borexp | | borrowers | | branchcategories | | branches | | branchrelations | | branchtransfers | | catalogueentry | | categories | | currency | | deletedbiblio | | deletedbiblioitems | | deletedborrowers | | deleteditems | | ethnicity | | issues | | issuingrules | | items | | itemsprices | | itemtypes | | marc_biblio | | marc_blob_subfield | | marc_breeding | | marc_subfield_structure | | marc_subfield_table | | marc_tag_structure | | marc_word | | marcrecorddone | | printers | | reserveconstraints | | reserves | | serial | | sessionqueries | | sessions | | shelfcontents | | statistics | | stopwords | | subscription | | subscriptionhistory | | suggestions | | systempreferences | | uploadedmarc | | userflags | | users | | websites | | z3950queue | | z3950results | | z3950servers | +-------------------------+ 72 rows in set
These tables can be divided into four groups:
tables holding descriptive data;
tables holding borrower data;
tables holding bibliographic data; and
tables holding transaction data