PAB3::DB::Max - Additional functions to PAB3::DB


PAB3 documentation  | view source Contained in the PAB3 distribution.

Index


NAME

Top

PAB3::DB::Max - Additional functions to PAB3::DB

SYNOPSIS

Top

  use PAB3::DB::Max;

  $data = $res->fetchall_arrayref();
  $data = $res->fetchall_arrayref( {} );
  $data = $stmt->fetchall_arrayref();
  $data = $stmt->fetchall_arrayref( {} );

  $data = $res->fetchall_hashref( $key );
  $data = $stmt->fetchall_hashref( $key );

  @row = $res->fetchrow_array();
  @row = $stmt->fetchrow_array();

  %row = $res->fetchrow_hash();
  %row = $stmt->fetchrow_hash();

  $row = $res->fetchrow_arrayref();
  $row = $stmt->fetchrow_arrayref();

  $row = $res->fetchrow_hashref();
  $row = $stmt->fetchrow_hashref();

  $data = $db->selectall_arrayref( $statement );
  $data = $db->selectall_arrayref( $statement, @bind_values );
  $data = $db->selectall_arrayref( $statement, {} );
  $data = $db->selectall_arrayref( $statement, {}, @bind_values );

  $data = $db->selectall_hashref( $statement, $key );
  $data = $db->selectall_hashref( $statement, $key, @bind_values );

  @row = $db->selectrow_array( $statement );
  @row = $db->selectrow_array( $statement, @bind_values );

  $row = $db->selectrow_arrayref( $statement );
  $row = $db->selectrow_arrayref( $statement, @bind_values );

  %row = $db->selectrow_hash( $statement );
  %row = $db->selectrow_hash( $statement, @bind_values );

  $row = $db->selectrow_hashref( $statement );
  $row = $db->selectrow_hashref( $statement, @bind_values );




DESCRIPTION

Top

PAB3::DB::Max provides additional functions to PAB3::DB. Once it has been loaded all functions becomes available to PAB3::DB.

EXAMPLES

  use PAB3::DB::Max;

  $db = PAB3::DB->connect( ... );

  $row = $db->selectrow_hashref( 'select * from table' );
  print $row->{'foo'}, "\n";

METHODS

Top

$res -> fetchrow_array ()
$stmt -> fetchrow_array ()

fetchrow_array() is a synonym for fetch_row()

$res -> fetchrow_hash ()
$stmt -> fetchrow_hash ()

fetchrow_hash() is a synonym for fetch_hash()

$res -> fetchrow_arrayref ()
$stmt -> fetchrow_arrayref ()

Fetches the next row of data and returns a reference to an array holding the field values or NULL if there are no more rows in result set. Null fields are returned as undef values in the array.

$res -> fetchrow_hashref ()
$stmt -> fetchrow_hashref ()

Fetches the next row of data and returns it as a reference to a hash containing field name and field value pairs or NULL if there are no more rows in result set. Null fields are returned as undef values in the hash.

$res -> fetchall_arrayref ()
$res -> fetchall_arrayref ( {} )
$stmt -> fetchall_arrayref ()
$stmt -> fetchall_arrayref ( {} )

Fetch all the data to be returned from a result or statement.

Parameters

{}

Fetch all fields of every row as a hash ref.

Return Values

It returns a reference to an array that contains one reference per row or NULL if there is no data.

$res -> fetchall_hashref ( $key )
$stmt -> fetchall_hashref ( $key )

Fetch all the data to be returned from a result or statement class as a reference to a hash containing a key for each distinct value of the $key column that was fetched.

Parameters

$key

Provides the name of the field that holds the value to be used for the key for the returned hash. For example:

  $res = $db->query( 'select id, name from table' );
  $data = $res->fetchall_hashref( 'id' );
  # print name of id = 2
  print $data->{2}->{'name'};

For queries returing more than one 'key' column, you can specify multiple column names by passing $key as a reference to an array containing one or more key column names. For example:

  $res = $db->query( 'select id1, id2, name from table' );
  $data = $res->fetchall_hashref( [ qw(id1 id2) ] );
  # print name of id1 = 2 and id2 = 10
  print $data->{2}->{10}->{'name'};




$db -> selectrow_array ( $statement )
$db -> selectrow_array ( $statement, @bind_values )

If @bind_values are not used, this method combines query() and fetchrow_array() into a single call.

If @bind_values are used, it combines prepare(), execute() and fetchrow_array().

$db -> selectrow_hash ( $statement )
$db -> selectrow_hash ( $statement, @bind_values )

If @bind_values are not used, this method combines query() and fetchrow_hash() into a single call.

If @bind_values are used, it combines prepare(), execute() and fetchrow_hash().

$db -> selectrow_arrayref ( $statement )
$db -> selectrow_arrayref ( $statement, @bind_values )

If @bind_values are not used, this method combines query() and fetchrow_arrayref() into a single call.

If @bind_values are used, it combines prepare(), execute() and fetchrow_arrayref().

$db -> selectrow_hashref ( $statement )
$db -> selectrow_hashref ( $statement, @bind_values )

If @bind_values are not used, this method combines query() and fetchrow_hashref() into a single call.

If @bind_values are used, it combines prepare(), execute() and fetchrow_hashref().

$db -> selectall_arrayref ( $statement )
$db -> selectall_arrayref ( $statement, {} )
$db -> selectall_arrayref ( $statement, @bind_values )
$db -> selectall_arrayref ( $statement, {}, @bind_values )

If @bind_values are not used, this method combines query() and fetchall_arrayref() into a single call.

If @bind_values are used, it combines prepare(), execute() and fetchall_arrayref().

$db -> selectall_arrayref ( $statement, $key )
$db -> selectall_arrayref ( $statement, $key, @bind_values )

If @bind_values are not used, this method combines query() and fetchall_hashref() into a single call.

If @bind_values are used, it combines prepare(), execute() and fetchall_hashref().

SEE ALSO

Top

Interface for database communication PAB3::DB.

AUTHORS

Top

Christian Mueller <christian_at_hbr1.com>

COPYRIGHT

Top


PAB3 documentation  | view source Contained in the PAB3 distribution.