Fix get_insert_id function of Net::MySQL
Posted by Thanadon February 6, 2007 at 12:32 pm 1 views
Filed under: Perl, Programming
After I try to find Pure Perl of MySQL network protocol interface, I've found Net::MySQL on CPAN but there have some problem if you use get_insert_id and AUTO_INCREMENT value of table more than 255 the function will always return 254.
Current version of Net::MySQL 0.09 released on 01 Apr 2006
Here is fixed
Assume that you install it at /usr/lib/perl5/site_perl/5.8.6/Net/MySQL.pm
change bold version to be the perl version that you installed.
Change from
To:
-
sub _get_insert_id
-
{
-
my $packet_lenght;
-
my $insert_id_value;
-
-
-
if ($packet_lenght == 7) {
-
} elsif ($packet_lenght == 8) {
-
} elsif ($packet_lenght == 9) {
-
} elsif ($packet_lenght == 10) {
-
} elsif ($packet_lenght> 10) {
-
} else {
-
}
-
return $insert_id_value;
-
}
I test and it work for my program.
Let me know if you have question or any problem to change.