Subject: | Make DBD::LDAP work with Class::DBI and a Netscape LDAP server (DBD/LDAP.pm patch) |
Okay, I uncommented some code that was on line (starting at) 613. The module was setting the type on -1, but when data came back from the Netscape LDAP which was an array of multiple values, my Class::DBI was empty (keys were created, values were undef). It was because the DBD::LDAP was returning -1 as type, which is not type VARCHAR! type 12 is a VARCHAR.
If you want more information about this patch, please do not hestitate to mail me. This code has been tested on a OpenLDAP server and a Netscape LDAP server, together with Class::DBI.
--- my_version/DBD/LDAP.pm 2005-04-13 14:01:00.277875120 +0200
+++ installed_version/DBD/LDAP.pm 2005-04-13 13:55:43.424044224 +0200
@@ -580,7 +580,6 @@
{
$retval = $resv[0];
my $dB = $sth->{Database};
-
if ($dB->FETCH('AutoCommit') == 1 && $sth->FETCH('Statement') !~ /^\s*select/i)
{
$dB->STORE('AutoCommit',0); #ADDED 20010911 AS PER SPRITE TO MAKE AUTOCOMMIT WORK.
@@ -600,7 +599,6 @@
#EVERYTHING WORKED, SO SAVE LDAP RESULT (# ROWS) AND FETCH FIELD INFO.
$sth->{'driver_rows'} = $resv[0]; # number of rows
- $sth->{'ldap_rows'} = $resv[0]; # number of rows
#### NOTE #### IF THIS FAILS, IT PROBABLY NEEDS TO BE "ldap_rows"?
@@ -613,14 +611,14 @@
@{$ldapref->{NAME}} = @l;
for my $i (0..$#l)
{
- ${$ldapref->{TYPE}}[$i] = $typehash{${$ldapref->{types}}{$l[$i]}};
- ${$ldapref->{PRECISION}}[$i] = ${$ldapref->{lengths}}{$l[$i]};
- ${$ldapref->{SCALE}}[$i] = ${$ldapref->{scales}}{$l[$i]};
+ #${$ldapref->{TYPE}}[$i] = $typehash{${$ldapref->{types}}{$l[$i]}};
+ #${$ldapref->{PRECISION}}[$i] = ${$ldapref->{lengths}}{$l[$i]};
+ #${$ldapref->{SCALE}}[$i] = ${$ldapref->{scales}}{$l[$i]};
#${$ldapref->{NULLABLE}}[$i] = 1;
#${$ldapref->{TYPE}}[$i] = 12; #VARCHAR
- #${$ldapref->{TYPE}}[$i] = -1; #VARCHAR
- #${$ldapref->{PRECISION}}[$i] = 255;
- #${$ldapref->{SCALE}}[$i] = 0;
+ ${$ldapref->{TYPE}}[$i] = -1; #VARCHAR
+ ${$ldapref->{PRECISION}}[$i] = 255;
+ ${$ldapref->{SCALE}}[$i] = 0;
${$ldapref->{NULLABLE}}[$i] = 1;
}
}
@@ -629,7 +627,7 @@
$sth->{'driver_data'} = \@resv;
$sth->STORE('ldap_data', \@resv);
- $sth->STORE('ldap_rows', ($resv[0])); # number of rows
+ $sth->STORE('ldap_rows', ($#resv+1)); # number of rows
$sth->{'TYPE'} = \@{$ldapref->{TYPE}};
$sth->{'NAME'} = \@{$ldapref->{NAME}};
$sth->{'PRECISION'} = \@{$ldapref->{PRECISION}};