MANUAL DE REFERENCIA DE DBI/DBD

Tabla de Contenidos


LA CLASE DBI

Los Métodos de la clase DBI

connect $dbh = DBI->connect("DBI:mysql:$database", $user, $password);
available_drivers @drivers = DBI->available_drivers;
data_sources @sources = DBI->data_sources($driver);
trace DBI->trace($trace_level);

Funciones de utilidades de DBI

neat $neat_value = DBI::neat($value, $maxlen);
neat_list $neat_list = DBI::neat_list($listref, $maxlen, $field_sep);
dump_results $rows = DBI::dump_results($sth, $maxlen, $lsep, $fsep, $fh);

Atributos dinámicos de DBI

$DBI::err see $dbh->err
$DBI::errstr see $dbh->errstr
$DBI::state see $dbh->state
$DBI::rows ? is this associated with $sth->rows ?

Métodos Comunes a Todos los Manejadores

err $err_code  =  $dbh->err;
errstr $err_string  =  $dbh->errstr;
state $state = $dbh->state;
trace $trace = $dbh->trace;
func $result = $dbh->func(@func_args, $func_name);

Atributos Comunes a Todos los Manejadores

Warn $dbh->{Warn} = 1;
CompatMode $dbh->{CompatMode} = 1;
InactiveDestroy $dbh->{InactiveDestroy} = 1;
PrintError $dbh->{PrintError} = 1;
RaiseError $dbh->{RaiseError} = 1;
ChopBlanks $dbh->{ChopBlanks} = 1;
LongReadLen $dbh->{LongReadLen} = 1;
LongTruncOk $dbh->{LongTruncOk} = 1;

Métodos de los Manejadores de BD

prepare $sth = $dbh->prpare($statement);
do $sth->$dbh->do($statement);
commit $dbh->commit; (Not supported by mySQL)
rollback $dbh->rollback; (Not supported by mySQL)
disconnect $dbh->disconnect;
ping $return = $dbh->ping;
quote $sql = $dbh->quote($string);

Métodos de los Manejadores de Sentencias

bind_param $sth->bind_param($param_num, $bind_value, $bind_type);
bind_param_inout $rv = $sth->bind_param_inout($param_num, \$bind_value, $max_len); 
(Not supported by mySQL)
execute $sth->execute;
fetchrow_arrayref $row_array = $sth->fetchrow_arrayref
fetchrow_array @row_array = $sth->fetchrow_array;
fetchrow_hashref $row_hash = $sth->fetchrow_hashref;
fetchall_arrayref $row_all = $sth->fetchall_arrayref;
finish $sth->finish;
rows $rc = $sth->rows;
bind_col $sth->bind_col($column_number, \$bind_var);
bind_columns $sth->bind_columns(\%attr, @bind_var_refs);

Atributos de los manejadores de Sentencias

NUM_OF_FIELDS $num_fields = $sth->{NUM_OF_FIELDS};
NUM_OF_PARAMS $num_params = $sth->{NUM_OF_PARAMS};
NAME $names = $sth->{NAME};
NULLABLE $nullables = $sth->{NULLABLE};
CursorName $cursor_name = $sth->{CursorName}; (?Not supported by mySQL?)

Depuración (Debugging)

DBI_TRACE DBI_TRACE = 2 perl test_script.pl

2000 Francisco Javier García Castellano. fjgc@decsai.ugr.es