One addendum I forgot to copy my DBConnect sub into the mail. Now
included.
> Hopefully this is the right place for this, if there is a list for
> DBIx::Recordset let me know.
>
> Started playing with DBIx::Recordset and I'm trying to initialize it
> with a DBI created database handle.
>
> Here is what the docs say:
>
> !DataSource
> Specifies the database to which to connect. This information can be
> given in the following ways:
> .....
> an DBI database handle
> Uses given database handle.
>
> So I tried this:
>
> *set = DBIx::Recordset -> Search ({'!DataSource'=> $iodbh,
> '!Table' => 'payroll',
> '$where' => 'APID = ? and paid
> = ?',
> '$values' => [$APID, 0] }) ;
>
> where $iodbh is a database handle. I'm sure the handle is good. I need
> to be able to connect this way because my app reads all the database
> passwords etc as root when apache launches (its mod_perl) and I need to
> keep the passwords out of the CGI scripts (ie not readable by web user).
>
> Error message I get is:
>
> Can't get DBI::db=HASH(0x9e11650)->{Name}: unrecognised attribute at
> /usr/local/lib/site_perl/DBIx/Recordset.pm line 178.
>
> Hoping this is just a syntax misunderstanding on my part. I have
> included the code from DBIx::Recordset below and my code that
> initializes the handle.
>
> Thanks.
>
> Here is the area around 178
>
> elsif (ref ($data_source) and eval { $data_source->isa('DBI::db') } )
> { # copy from database handle
> $self->{'*Driver'} = $data_source->{'Driver'}->{'Name'} ;
> 178: $self->{'*DataSource'} = $data_source->{'Name'} ;
> # DBI does not save user name
> $self->{'*Username'} = undef ;
> $self->{'*DBHdl'} = $data_source ;
> # XXX no idea how to fetch attr hash other than handle itself
> $self->{'*DBIAttr'} = {} ;
> $self->{'*MainHdl'} = 0 ;
> }
>
> This is my code initializing the database handle:
>
> $Inouthandle ||= DBConnect (
> hostname => $server,
> database => $AsqlConfig::systemdatabase,
> username => $AsqlConfig::systemuser,
> passwd => $AsqlConfig::systempassword,
> driver => $AsqlConfig::systemdriver,
> );
sub DBConnect {
my %args = (
hostname => 'localhost',
database => 'db',
username => 'dbadmin',
passwd => 'secritpassward',
driver => 'mysql',
@_,
);
my $activedatabase =
DBI->connect("DBI:$args{driver}:dbname=$args{database};host=$args{hostname}",$args{username},$args{passwd});
if ( !defined $activedatabase ) {
die "Cannot do
\$activedatabase->connect: $DBI::errstr\n";
}
return $activedatabase;
};
>
>
> Wade
>
> --
> Wade Burgett
> Burgett Systems
> http://www.burgettsys.com/
> [EMAIL PROTECTED]
--
Wade Burgett
Burgett Systems
http://www.burgettsys.com/
[EMAIL PROTECTED]