Author: timbo
Date: Tue Jun 6 02:49:10 2006
New Revision: 6475
Modified:
dbi/trunk/Changes
dbi/trunk/DBI.pm
dbi/trunk/DBI.xs
dbi/trunk/Perl.xs
Log:
Added docs for $sth->{ParamArrays} thanks to Martin J. Evans.
Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes (original)
+++ dbi/trunk/Changes Tue Jun 6 02:49:10 2006
@@ -4,7 +4,7 @@
=cut
-=head2 Changes in DBI 1.51 (svn rev 6349), 26 May 2006
+=head2 Changes in DBI 1.51 (svn rev 6475), 6th June 2006
Fixed $dbh->clone method 'signature' thanks to Jeffrey Klein.
Fixed default ping() method to return false if !$dbh->{Active}.
@@ -33,6 +33,7 @@
Added 'fetch array of hash refs' example to selectall_arrayref
docs thanks to Tom Schindl.
+ Added docs for $sth->{ParamArrays} thanks to Martin J. Evans.
Added reference to $DBI::neat_maxlen in TRACING section of docs.
Added ability for DBI::Profile Path to include attributes
and a summary of where the code was called from.
Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm (original)
+++ dbi/trunk/DBI.pm Tue Jun 6 02:49:10 2006
@@ -5478,7 +5478,8 @@
The C<ArrayTupleStatus> attribute can be used to specify a
reference to an array which will receive the execute status of each
-executed parameter tuple.
+executed parameter tuple. Note the C<ArrayTupleStatus> attribute was
+mandatory until DBI 1.38.
For tuples which are successfully executed, the element at the same
ordinal position in the status array is the resulting rowcount.
@@ -6164,6 +6165,39 @@
The C<ParamValues> attribute was added in DBI 1.28.
+=item C<ParamArrays> (hash ref, read-only)
+
+Returns a reference to a hash containing the values currently bound to
+placeholders with L</execute_array> or L</bind_param_array>. The
+keys of the hash are the 'names' of the placeholders, typically
+integers starting at 1. Returns undef if not supported by the driver
+or no arrays of parameters are bound.
+
+Each key value is an array reference containing a list of the bound
+parameters for that column.
+
+For example:
+
+ $sth = $dbh->prepare("INSERT INTO staff (id, name) values (?,?)");
+ $sth->execute_array({},[1,2], ['fred','dave']);
+ if ($sth->{ParamArrays}) {
+ foreach $param (keys %{$sth->{ParamArrays}}) {
+ printf "Parameters for %s : %s\n", $param,
+ join(",", @{$sth->{ParamArrays}->{$param}});
+ }
+ }
+
+It is possible that the values in the hash returned by C<ParamArrays>
+are not I<exactly> the same as those passed to L</bind_param_array> or
+L</execute_array>. The driver may have slightly modified values in some
+way based on the TYPE the value was bound with. For example a floating
+point value bound as an SQL_INTEGER type may be returned as an
+integer.
+
+It is also possible that the keys in the hash returned by
+C<ParamArrays> are not exactly the same as those implied by the
+prepared statement. For example, DBD::Oracle translates 'C<?>'
+placeholders into 'C<:pN>' where N is a sequence number starting at 1.
=item C<ParamTypes> (hash ref, read-only)
Modified: dbi/trunk/DBI.xs
==============================================================================
--- dbi/trunk/DBI.xs (original)
+++ dbi/trunk/DBI.xs Tue Jun 6 02:49:10 2006
@@ -1970,7 +1970,7 @@
}
}
- /* finally check the actual hash just in case */
+ /* finally check the actual hash */
if (valuesv == Nullsv) {
valuesv = &sv_undef;
cacheit = 0;
@@ -1981,6 +1981,7 @@
if ( !( (*key=='H' && strEQ(key, "HandleError"))
|| (*key=='H' && strEQ(key, "HandleSetErr"))
|| (*key=='S' && strEQ(key, "Statement"))
+ || (*key=='P' && strEQ(key, "ParamArrays"))
|| (*key=='P' && strEQ(key, "ParamValues"))
|| (*key=='P' && strEQ(key, "Profile"))
|| (*key=='C' && strEQ(key, "CursorName"))
Modified: dbi/trunk/Perl.xs
==============================================================================
--- dbi/trunk/Perl.xs (original)
+++ dbi/trunk/Perl.xs Tue Jun 6 02:49:10 2006
@@ -40,6 +40,7 @@
dbd_st_rows(SV *h, imp_sth_t *imp_sth)
{
dTHX;
+ h = h; /* silence unused var warning */
DBIh_SET_ERR_CHAR(h, imp_sth, 0, 1, "err msg", "12345", Nullch);
return -1;
}