<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Korerorero &#187; DBIx::Class</title>
	<atom:link href="http://blog.bigballofwax.co.nz/tag/dbixclass/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bigballofwax.co.nz</link>
	<description>Just random ranting and raving</description>
	<lastBuildDate>Thu, 26 Aug 2010 09:51:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>DBIx::Class and Koha</title>
		<link>http://blog.bigballofwax.co.nz/2009/07/25/dbixclass-and-koha/</link>
		<comments>http://blog.bigballofwax.co.nz/2009/07/25/dbixclass-and-koha/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 08:47:31 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[Koha]]></category>
		<category><![CDATA[DBIx::Class]]></category>

		<guid isPermaLink="false">http://blog.bigballofwax.co.nz/?p=1195</guid>
		<description><![CDATA[I did some work today with DBIx::Class and Koha, and got opac-account.pl partially using it. You can see the schema here and I had to make a few changes to C4::Context, and a few to opac-account.pl. Here is what they were. diff --cc C4/Context.pm index 7ba57fb,4dab9a9..cafc0ca --- a/C4/Context.pm +++ b/C4/Context.pm @@@ -18,6 -18,6 +18,8 @@@ [...]]]></description>
			<content:encoded><![CDATA[<p>I did some work today with DBIx::Class and Koha, and got opac-account.pl partially using it.</p>
<p>You can see the <a href="http://git.workbuffer.org/cgi-bin/gitweb.cgi?p=koha.git;a=tree;f=lib/Koha/Schema;h=f04cfa39433ef6a18d19523f3e8197d62676d5c8;hb=b68bfca6c905aef52096c70c7c0a811162b72199">schema here </a>and I had to make a few changes to C4::Context, and a few to opac-account.pl.</p>
<p>Here is what they were.</p>
<pre>diff --cc C4/Context.pm
index 7ba57fb,4dab9a9..cafc0ca
--- a/C4/Context.pm
+++ b/C4/Context.pm
@@@ -18,6 -18,6 +18,8 @@@ package C4::Context</pre>
<pre>use strict;
use warnings;
++use Koha::Schema;
++
use vars qw($VERSION $AUTOLOAD $context @context_stack);</pre>
<pre>BEGIN {
@@@ -191,6 -191,6 +193,27 @@@ $context = undef;        # Initially, n</pre>
<pre>=cut</pre>
<pre>++sub schema {
++    my $self = shift;
++    my $db_driver;
++    if ($context-&gt;config("db_scheme")){
++        $db_driver=db_scheme2dbi($context-&gt;config("db_scheme"));
++    }
++    else {
++        $db_driver="mysql";
++    }
++
++    my $db_name   = $context-&gt;config("database");
++    my $db_host   = $context-&gt;config("hostname");
++    my $db_port   = $context-&gt;config("port") || '';
++    my $db_user   = $context-&gt;config("user");
++    my $db_passwd = $context-&gt;config("pass");
++    my $schema = Koha::Schema-&gt;connect( "DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",
++      $db_user, $db_passwd);
++    return $schema;
++}
++
++
sub KOHAVERSION {
my $cgidir = C4::Context-&gt;intranetdir;</pre>
<pre>diff --cc opac/opac-account.pl
index 43a1e0c,43a1e0c..376ae98
--- a/opac/opac-account.pl
+++ b/opac/opac-account.pl
@@@ -17,16 -17,16 +17,20 @@@</pre>
<pre># wrriten 15/10/2002 by finlay@katipo.oc.nz
# script to display borrowers account details in the opac
++# Edited by chrisc@catalyst.net.nz</pre>
<pre>use strict;
use CGI;
use C4::Members;
++use C4::Context;
use C4::Circulation;
use C4::Auth;
use C4::Output;
use C4::Dates qw/format_date/;
++use DBIx::Class::ResultClass::HashRefInflator;
use warnings;</pre>
<pre>++
my $query = new CGI;
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
@@@ -40,9 -40,9 +44,16 @@@
);</pre>
<pre># get borrower information ....
--my $borr = GetMemberDetails( $borrowernumber );
++# my $borr = GetMemberDetails( $borrowernumber );
++my $context = C4::Context-&gt;new;
++my $schema = $context-&gt;schema;
++my $rs = $schema-&gt;resultset('Borrowers')-&gt;search({ borrowernumber =&gt; $borrowernumber });
++$rs-&gt;result_class('DBIx::Class::ResultClass::HashRefInflator');
++my $borr = $rs-&gt;first;
++use Data::Dumper;
++warn Dumper $borr;
my @bordat;
--$bordat[0] = $borr;
++push @bordat,$borr;</pre>
<pre>$template-&gt;param( BORROWER_INFO =&gt; \@bordat );</pre>
<p>So not many changes at all, i&#8217;ll work on changing some more, but it looks like adding DBIx::Class can be done in a gradual way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigballofwax.co.nz/2009/07/25/dbixclass-and-koha/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
