package Mysql
::Statement
;
@Mysql::Statement
::ISA
= qw(DBI::st);
use vars
qw($VERSION $AUTOLOAD);
my $ref = $self->fetchrow_arrayref;
wantarray ? @$ref : $ref->[0];
my($ref) = $self->fetchrow_hashref;
while ($ref = $self->fetchrow_arrayref) {
push(@col, $ref->[$colNum]);
$self->func($pos, 'dataseek');
sub numrows { my($self) = shift; $self->rows() }
sub numfields { my($self) = shift; $self->{'NUM_OF_FIELDS'} }
my $arr = $self->{$attr};
sub table ($) { shift->arrAttr('mysql_table') }
sub name ($) { shift->arrAttr('NAME') }
*affectedrows = \&numrows;
sub insertid { my($self) = shift; $self->{'mysql_insertid'} }
sub type ($) { shift->arrAttr('mysql_type') }
my $arr = [map {!$_} @{shift()->{'NULLABLE'}}];
wantarray ? @$arr : $arr;
sub isprikey ($) { shift->arrAttr('mysql_is_pri_key') }
sub isnum ($) { shift->arrAttr('mysql_is_num') }
sub isblob ($) { shift->arrAttr('mysql_is_blob') }
sub length ($) { shift->arrAttr('PRECISION') }
if (!($result = $sth->{'mysql_maxlength'})) {
for (my $i = 0; $i < $sth->numfields(); $i++) {
my $numRows = $sth->numrows();
for (my $j = 0; $j < $numRows; $j++) {
my @row = $sth->fetchrow;
for (my $i = 0; $i < @row; $i++) {
my $l = CORE::length($s);
# New in 2.0: a string is longer than it should be
if (defined &Msql::TEXT_TYPE &&
$sth->type->[$i] == &Msql::TEXT_TYPE &&
$l > $sth->length->[$i] + 5) {
substr($s,$sth->length->[$i]) = "...($l)";
$result->[$i] = $l if $l > $result->[$i];
return wantarray ? @$result : $result;
# Allow them to say fetch_row or FetchRow
Carp::croak ("$AUTOLOAD not defined and not autoloadable");
$x =~ s/([\001-\037\177])/sprintf("\\%03o",unpack("C",$1))/eg;
my($plusline,$titline,$sprintf) = ('+','|','|');
if ($sth->numfields == 0) {
for (0..$sth->numfields-1) {
$l=CORE::length($sth->name->[$_]);
if ($l < $sth->maxlength->[$_]) {
$l= $sth->maxlength->[$_];
if (!$sth->isnotnull && $l < 4) {
$plusline .= sprintf "%$ {l}s+", "-" x $l;
$l= -$l if (!$sth->isnum->[$_]);
$titline .= sprintf "%$ {l}s|", $sth->name->[$_];
$result = "$plusline\n$titline\n$plusline\n";
while (@row = $sth->fetchrow) {
my ($col, $pcol, @prow, $i, $j);
for ($i = 0; $i < $sth->numfields; $i++) {
$pcol = defined $col ? unctrl($col) : "NULL";
$result .= sprintf $sprintf, @prow;
$result .= "$plusline\n";
$s = $sth->numrows == 1 ? "" : "s";
$result .= $sth->numrows . " row$s processed\n\n";