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?

In reply to net::mysql has_selected_record always returns true by steve_s741

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.