Author: timbo
Date: Fri Dec 17 05:03:43 2004
New Revision: 634

Modified:
   dbi/trunk/lib/DBD/ExampleP.pm
   dbi/trunk/lib/DBI/DBD.pm
Log:
More doc tweaks thanks to Steffen Goeldner


Modified: dbi/trunk/lib/DBD/ExampleP.pm
==============================================================================
--- dbi/trunk/lib/DBD/ExampleP.pm       (original)
+++ dbi/trunk/lib/DBD/ExampleP.pm       Fri Dec 17 05:03:43 2004
@@ -58,13 +58,10 @@
 
     sub connect { # normally overridden, but a handy default
         my($drh, $dbname, $user, $auth)= @_;
-        my($this) = DBI::_new_dbh($drh, {
-           'Name' => $dbname,
-           'User' => $user,
-           examplep_get_info => {},
-           });
-       $this->STORE(Active => 1);
-        $this;
+        my ($outer, $dbh) = DBI::_new_dbh($drh, { Name => $dbname });
+        $dbh->STORE('Active', 1);
+        $dbh->{examplep_get_info} = {};
+        return $outer;
     }
 
     sub data_sources {
@@ -97,7 +94,7 @@
            # No we have DBI::DBM etc ExampleP should be deprecated
        }
 
-       my ($outer, $inner) = DBI::_new_sth($dbh, {
+       my ($outer, $sth) = DBI::_new_sth($dbh, {
            'Statement'     => $statement,
        }, ['example implementors private data '.__PACKAGE__]);
 
@@ -109,7 +106,7 @@
 
        $outer->STORE('NUM_OF_FIELDS' => scalar(@fields));
 
-       $inner->{'dbd_ex_dir'} = $dir if defined($dir) && $dir !~ /\?/;
+       $sth->{dbd_ex_dir} = $dir if defined($dir) && $dir !~ /\?/;
        $outer->STORE('NUM_OF_PARAMS' => ($dir) ? $dir =~ tr/?/?/ : 0);
 
        if (@fields) {

Modified: dbi/trunk/lib/DBI/DBD.pm
==============================================================================
--- dbi/trunk/lib/DBI/DBD.pm    (original)
+++ dbi/trunk/lib/DBI/DBD.pm    Fri Dec 17 05:03:43 2004
@@ -622,7 +622,7 @@
 The I<driver> method is the driver handle constructor. It's a
 reasonable example of how DBI implements its handles. There are three
 kinds: B<driver handles> (typically stored in C<$drh>; from now on
-called C<drh> of C<$drh>), B<database handles> (from now on called C<dbh> or
+called C<drh> or C<$drh>), B<database handles> (from now on called C<dbh> or
 C<$dbh>) and B<statement handles> (from now on called C<sth> or
 C<$sth>).
 
@@ -664,7 +664,7 @@
 interpreter:
 
   sub CLONE {
-    undef $rdh;
+    undef $drh;
   }
 
 =head3 The DBD::Driver::dr package
@@ -700,7 +700,7 @@
 
       # Process attributes from the DSN; we assume ODBC syntax
       # here, that is, the DSN looks like var1=val1;...;varN=valN
-      foreach my $var ( split /;/, $dbname ) {
+      foreach my $var ( split /;/, $dr_dsn ) {
           my ($attr_name, $attr_value) = split '=', $var, 2;
          return $drh->set_err(1, "Can't parse DSN part '$var'")
               unless defined $attr_value;
@@ -723,10 +723,10 @@
 
       # Assume you can attach to your database via drv_connect:
       my $connection = drv_connect($db, $host, $port, $user, $auth)
-          or return $drh->set_err(1, "Can't connect to $dbname: ...");
+          or return $drh->set_err(1, "Can't connect to $dr_dsn: ...");
 
       # create a 'blank' dbh (call superclass constructor)
-      my ($outer, $dbh) = DBI::_new_dbh($drh, { Name => $dbname });
+      my ($outer, $dbh) = DBI::_new_dbh($drh, { Name => $dr_dsn });
 
       $dbh->STORE('Active', 1 );
       $dbh->{drv_connection} = $connection;
@@ -775,7 +775,7 @@
 
   sub data_sources
   {
-      my($srh, $attr) = @_;
+      my($drh, $attr) = @_;
       my(@list) = ();
       # You need more sophisticated code than this to set @list...
       push @list, "dbi:Driver:abc";
@@ -996,7 +996,7 @@
           my $dbh = $sth->{Database};
           $val = $dbh->quote($sth, $type);
       }
-      my $params = $sth->FETCH('drv_params');
+      my $params = $sth->{drv_params};
       $params->[$pNum-1] = $val;
       1;
   }
@@ -1009,7 +1009,7 @@
       $sth->finish if $sth->FETCH('Active');
 
       my $params = (@bind_values) ?
-          [EMAIL PROTECTED] : $sth->FETCH('drv_params');
+          [EMAIL PROTECTED] : $sth->{drv_params};
       my $numParam = $sth->FETCH('NUM_OF_PARAMS');
       return $sth->set_err(1, "Wrong number of parameters")
           if @$params != $numParam;
@@ -1028,8 +1028,8 @@
 There are a number of things you should note here.
 We setup the NUM_OF_FIELDS attribute
 here, because this is essential for I<bind_columns> to work.
-We use attribute I<$sth->{'Statement'}> which we created
-within I<prepare>. The attribute I<$sth->{'Database'}>, which is
+We use attribute C<$sth-E<gt>{Statement}> which we created
+within I<prepare>. The attribute C<$sth-E<gt>{Database}>, which is
 nothing else than the I<dbh>, was automatically created by DBI.
 
 Finally note that (as specified in the DBI specification) we return the
@@ -1048,10 +1048,10 @@
   sub fetchrow_arrayref
   {
       my ($sth) = @_;
-      my $data = $sth->FETCH('drv_data');
+      my $data = $sth->{drv_data};
       my $row = shift @$data;
       if (!$row) {
-          $sth->STORE(Active => 0); # mark as no longer active 
+          $sth->STORE(Active => 0); # mark as no longer active
           return undef;
       }
       if ($sth->FETCH('ChopBlanks')) {
@@ -1061,8 +1061,6 @@
   }
   *fetch = \&fetchrow_arrayref; # required alias for fetchrow_arrayref
 
-  sub rows { shift->FETCH('drv_rows') }
-
 Note the use of the method I<_set_fbav>: This is required so that
 I<bind_col> and I<bind_columns> work.
 
@@ -1070,6 +1068,15 @@
 can't be fetched then Active should be turned off
 before the method returns.
 
+The rows method for this driver can be implemented like this:
+
+  sub rows { shift->{drv_rows} }
+
+because it knows in advance how many rows it has fetched.
+Alternatively you could delete that method and so fallback
+to the DBI's own method which does the right thing based
+on the number of calls to _set_fbav().
+
 =head4 Statement attributes
 
 The main difference between dbh and sth attributes is, that you

Reply via email to