Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Using Data::Dumper on a MySQL statement handle

by Anonymous Monk
on Nov 10, 2010 at 16:42 UTC ( [id://870621]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello. I have used Data::Dumper successfully but I am stumped if I can even use it on this.
I have a statement handle in my code that's pretty straight forward.
$dbh= DBConnect::connect(); #Established connection $sth = $dbh->prepare("SELECT * FROM test WHERE 1"); print Dumper($sth)
The DBI is being subclassed in DBConnect to add comments to the SQL statement. I need to write a unit test right now to check the SELECT before it being executed.
This is all a roundabout way of asking if it's possible to use Dumper on $sth (or $dbh) to see what the parameters are and to verify that the comments are correctly attached to the SQL statement.
Many thanks ahead for the advice.

Replies are listed 'Best First'.
Re: Using Data::Dumper on a MySQL statement handle
by umasuresh (Hermit) on Nov 10, 2010 at 17:04 UTC
      That's a great link! It isn't the results I'm concerned with, since they are just fine. It's the actual SQL statement that is being sent that I'm interested in checking. I just need to be able to check the SQL statement from the $sth object to verify that the subclassing was successful.

        I may be misunderstanding but can't you just look at the Statement attribute?

Re: Using Data::Dumper on a MySQL statement handle
by kcott (Archbishop) on Nov 10, 2010 at 17:14 UTC

    What part of this has you stumped?

    Please show the output of print Dumper($sth) (which should have a terminal semicolon, by the way) and identify what aspect of this you are having difficulty with.

    -- Ken

      Ooops, that would be much more helpful. Here's the Dumper output.
      $VAR1 = bless( {}, 'DBI::st' );

        This sounds like a follow-up to Perl DBI: Overloading statement handle. If so, can you post the code that you finally came up with. Actually, even if it's something completely different, still post the code.

        Also, can you run print Dumper($dbh);, and post that output too.

        -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://870621]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found