Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

On a note totally unrelated to your question, I couldn't help but notice your SQL:

SELECT * FROM emails

I do a lot of heavy database work and I've been bitten by this type of SQL many times. As a general rule, when trying to write maintainable code, it's a good idea to be very specific about what you will allow. For example, consider the following SQL statement:

SELECT userid, email, contest FROM emails

That SQL statement has a variety of benefits:

  1. It's immediately obvious to the maintenance programmer exactly what is being requested.
  2. It's more efficient than selecting a bunch of columns you don't need, if you have more columns in the table than you're actually using.
  3. If you do a $sth->fetchrow_arrayref, you don't have to worry about columns in the database being reordered.
  4. If someone renames a column, you will understand faster why your $ref->{'contest'} autovivified a hash entry and produced an undef value.
  5. If someone removes a column from the database, you get the same benefit as mentioned in the fourth point.

If you're just writing a small program, or use very simple logic as what you have above, these issues may be less likely to impact you. However, as you do more and more work with databases, getting in the habit of stating explicitly what you want will reap tremendous rewards.

Cheers,
Ovid

Vote for paco!

The title of this node is a reference to Death to Dot Star!, for those who may be confused.

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid: Death to Select Star!) Re: MySQL DBI Help by Ovid
in thread MySQL DBI Help by Anonymous Monk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-23 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found