Mailing List Archive

More questions
Hi

1. DBIxRecordset: How do I put the PrevNextForm in a table ? I want to alwas
have the same buttons the same place in the form, like this

First Previous Next Last

If displaying the first rows,
it would look like

Next Last

Hope it is understandable.

2. Could someone please tell me how I make a persistent database connection
with mod_perl and Embperl ? A step by step intro including
- where do I make the DBI->connect. In startup.pl ?
- How do I reference the database handle? What name does it have ?

According to the mod_perl guide, this is preferable to put in startup.pl

use mymodule();

to save time by including all the routines on startup. But if I do so, I can
not access any routines in mymodule. They are simple not known.
Why ?

--
Kaare Rasmussen --Linux, spil,-- Tlf: 3816 2582
Kaki Data tshirts, merchandize Fax: 3816 2582
Howitzvej 75 Åben 14.00-18.00 Email: kar@webline.dk
2000 Frederiksberg Lørdag 11.00-17.00 Web: www.suse.dk
RE: More questions [ In reply to ]
Hi
>
> 1. DBIxRecordset: How do I put the PrevNextForm in a table ? I
> want to alwas
> have the same buttons the same place in the form, like this
>
> First Previous Next Last
>
> If displaying the first rows,
> it would look like
>
> Next Last
>
> Hope it is understandable.
>

Yes, I understand, but the current version don't displays First and
Previous, if you are already at the start of the recordset. If you need
this, you must patch DBIx::Recordset PrevNextForm method.

> 2. Could someone please tell me how I make a persistent database
> connection
> with mod_perl and Embperl ? A step by step intro including
> - where do I make the DBI->connect. In startup.pl ?

Never make a connect in the startup.pl, unless you also make a disconnect!
(because db handles becomes invalid when APache forks it childs)

> - How do I reference the database handle? What name does it have ?
>

In your startup.pl inlcude a

use Apache::DBI ;

afterwards you can just access your database as normal. Apache::DBI takes
care for you.


> According to the mod_perl guide, this is preferable to put in startup.pl
>
> use mymodule();
>
> to save time by including all the routines on startup. But if I
> do so, I can
> not access any routines in mymodule. They are simple not known.
> Why ?
>

Because your routines will live in the main package. Include a

package mymodule ;

at the top of your module and access the functions via

mymodule::foo () ;

Gerald



> --
> Kaare Rasmussen --Linux, spil,-- Tlf: 3816 2582
> Kaki Data tshirts, merchandize Fax: 3816 2582
> Howitzvej 75 Åben 14.00-18.00 Email: kar@webline.dk
> 2000 Frederiksberg Lørdag 11.00-17.00 Web: www.suse.dk
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
RE: More questions [ In reply to ]
>
> (PrevNext question)
> > Yes, I understand, but the current version don't displays First and
> > Previous, if you are already at the start of the recordset. If you need
>
> I don't want that - I want to somehow tableize it, so I can have
> a blank space
> where the First and Previous buttons should have been, if they had been
> usefull. The idea is to help the user, giving the same buttons
> the same place,
> and therefore the user will know where to push with a minimum of reading.
>

Then I think you should split up the result of PrevNextForm somehow and
reassemble it in the desired way.

>
> > afterwards you can just access your database as normal.
> Apache::DBI takes
> > care for you.
>
> I don't get it. Will I have to put something likge
> $db = DBI->connect("dbi:Pg:dbname=$dbname") or die("Unable to
> connect to $dbname");
>
> all over the place?
>
> I thought that somehow I would have a $db variable to use.
>

If you use plain DBI, you have to go that way. Of course you can hide this
in a custom module.

If you use DBIx::Recordset, you can create a DBIx::Database object in your
startup.pl file and refer to it inside your scripts, like:

[.-
*set = DBIx::Recordset -> Search ({ '!DataSource' => $main::db, '!Table' =>
.... }) ;
-]

> (module inclusion)
> > package mymodule ;
> > at the top of your module and access the functions via
> > mymodule::foo () ;
>
> Ugh! So I have to put ::'s all over the place :-( This should work, but
> doesn't:
>
> use mymodule qw(foo);
>
> $bar = foo(1234);
>

This only works if you export the function foo from mymodule. Then it will
work, of course. The perlmod manpage should give you some information on how
to do it.

Gerald



-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------