Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm a perl beginner so i apologise for the basic question. What is $h on the perl dbi docs. This code is taken from the first bit of code on the dbi page. At the bottom is a variable $h.
It also comes up later.use DBI; @driver_names = DBI->available_drivers; %drivers = DBI->installed_drivers; @data_sources = DBI->data_sources($driver_name, \%attr); $dbh = DBI->connect($data_source, $username, $auth, \%attr); $rv = $dbh->do($statement); $rv = $dbh->do($statement, \%attr); $rv = $dbh->do($statement, \%attr, @bind_values); $ary_ref = $dbh->selectall_arrayref($statement); $hash_ref = $dbh->selectall_hashref($statement, $key_field); $ary_ref = $dbh->selectcol_arrayref($statement); $ary_ref = $dbh->selectcol_arrayref($statement, \%attr); @row_ary = $dbh->selectrow_array($statement); $ary_ref = $dbh->selectrow_arrayref($statement); $hash_ref = $dbh->selectrow_hashref($statement); $sth = $dbh->prepare($statement); $sth = $dbh->prepare_cached($statement); $rc = $sth->bind_param($p_num, $bind_value); $rc = $sth->bind_param($p_num, $bind_value, $bind_type); $rc = $sth->bind_param($p_num, $bind_value, \%attr); $rv = $sth->execute; $rv = $sth->execute(@bind_values); $rv = $sth->execute_array(\%attr, ...); $rc = $sth->bind_col($col_num, \$col_variable); $rc = $sth->bind_columns(@list_of_refs_to_vars_to_bind); @row_ary = $sth->fetchrow_array; $ary_ref = $sth->fetchrow_arrayref; $hash_ref = $sth->fetchrow_hashref; $ary_ref = $sth->fetchall_arrayref; $ary_ref = $sth->fetchall_arrayref( $slice, $max_rows ); $hash_ref = $sth->fetchall_hashref( $key_field ); $rv = $sth->rows; $rc = $dbh->begin_work; $rc = $dbh->commit; $rc = $dbh->rollback; $quoted_string = $dbh->quote($string); $rc = $h->err; <<<<<<<<<<<<<<<<<<<<<<<< $str = $h->errstr; $rv = $h->state; $rc = $dbh->disconnect;
thanks a lotuse Carp; $h->{HandleError} = sub { confess(shift) };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: what is $h in the dbi
by AnomalousMonk (Archbishop) on Dec 22, 2010 at 04:35 UTC | |
by ikegami (Patriarch) on Dec 22, 2010 at 17:07 UTC | |
by Anonymous Monk on Dec 22, 2010 at 18:06 UTC | |
by ikegami (Patriarch) on Dec 22, 2010 at 18:14 UTC |