Hello
I need to write a Dancer Application where I need to connect to Microsoft Access 97/2003 Database... :'(

I use DBI::Proxy

my $dsn      = "DBI:Proxy:hostname=$IP;port=$PORT;dsn=DBI:ODBC:$ODBC";
my $dbh = DBI->connect($dsn, "", "") || die "Erreur de connexion à la base";
$dbh->{AutoCommit} = 1;
$dbh->{RaiseError} = 1;

it's not fast but it's works.

I tried to use Dancer::Plugin::Database but Microsoft SQL is not compatible ( Limit doesn't exist, this is TOP etc.. )

my %ClientParc ;
$sql =q/SELECT Spécifique, Quantité, PrixMaintenance FROM ClientParc WHERE NumContrat=? AND CodeClient=?/;
$stha = $dbha->prepare($sql);
$stha->execute($NumContrat, $CodeClient );
while (my ($Specifique, $Quantite, $PrixMaintenance) = $stha->fetchrow_array()) { $ClientParc{$Specifique} = { Specifique => $Specifique, Quantite => $Quantite, PrixMaintenance => $PrixMaintenance }
}

 I create a hash %ClientParc and I send it to TTK
and I do

return template '/echeancier' => {
    ClientParc => \%ClientParc
}
in my view

[% FOREACH s IN ClientParc.values -%]

        [%- IF loop.first %]
<div class="span5"> [% s.Quantite %] [% s.Specifique %] </div>
        [% ELSE %]
<div class="span5 offset5"> [% s.Quantite %] [% s.Specifique %] </div>
        [% END %]
[% END %]

And it's works but

I got 2 questions
1 ) are they a better solution ?
2) for each page , I need to connect to MS Access proxy and this is slow ( 2 ou 3 sec for connection, but after queries are enough fast ), are they a solution to maintain a DB connection ?

thanks
Hugues.

_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to