Salutations sooth bearers,

I have a problem, which I'm nearly certain is one of oversight, but I'm a perl novice and apparently going blind so I'd really appreciate some quick advice.

The setup involves modularised dbi routines to delete a row from MySQL. I've managed to work (read: blunt trauma) my head around problems I had with all other types of SQL calls and dereferencing results, but I feel like DBI.pm has some abtuse, unspoken rule used to force us into the celebate life.

Anyway, the (edited) code:

sub remove { ( my @dat = @_ ) =~ /^\d+$/; my $statement = qq~DELETE FROM `gates-post` WHERE id = "$dat[1]"~; get( "affected" ); return( undef ) unless( $rows > 0 ); sub get { my $opt = shift; ( $rows, @rtn ) = ''; $dbh = DBI->connect( gates->url, gates->accessName, gates->passs, +{ AutoCommit => 1, RaiseError => 1 }) || die "DB connect failed: " + . $dbh->errstr; . . . if ( $opt eq "affected" ) { $rows = $dbh->do( $statement ) or die "DB operation failed to +affect: " . $dbh->errstr; return; }
The problems:
Basically, nothing is deleted. However, I know that the statement is formatted properly (and will delete the right row if I stick it through phpMyAdmin for instance); I know that $rows (global var) is returned and has value 1; I'm also sure that the right method 'do' is called. I've tried the extended version of do but since it works for the other calls to it I don't understand why it pretends to succeed for DELETE statements.

I can't get the local 'ward' out of the corner of my eye, so any help would be much appreciated (as would any unrelated 'criticism', of course).

Cheers.


In reply to DBI, rows, and do by drrngrvy

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.