Irrespective of whether the SQL results in records being returned or not, this has_selected_record method of net::mysql always seems to return true. This exact issue has been raised before (http://www.perlmonks.org/?node_id=482863) and there is no sign of a resolution within that thread. This has had me tearing my hair out for days. I've simplified my script down to bare bones and still get the same result. Surely, if anyone out there is using net::mysql, this issue must have been experienced by others. Surely?
So, here is the code that I run against the empty 'orders' table in my 'invemtory' database:
use DBI;
use Net::MySQL;
my $mysql = Net::MySQL->new(
hostname => '127.0.0.1:8889', # Default use UNIX socket
database => 'inventory',
user => 'root',
password => 'root'
);
$mysql->query(q{select * from orders});
if ($mysql->has_selected_record) {
print "found in DB...\n";
}
And the output:
bash-3.2$ perl -T test.pl
found in DB...
A lot of people seem to suggest using DBD::mysql instead. I have used DBD::mysql n other platforms but getting it to work on Mac OS-X has proven to be beyond me. I read a post somewhere suggesting to try net::mysql and that's how I ended up in this rabbit hole. Is this module supported or is it a dead end?