Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Re: Dereferencing and DBI methods

by Cirollo (Friar)
on Jul 25, 2001 at 04:03 UTC ( #99523=note: print w/replies, xml ) Need Help??

in reply to Re: Dereferencing and DBI methods
in thread Dereferencing and DBI methods

You just made it look like the first example.

My point is that some of the aggregate functions only return refs, and don't have a counterpart that returns an actual array. selectcol_arrayref, fetchall_arrayref, fetchrow_hashref to name a few. So, you have to either dereference them when you make the call, or use an intermediate variable, or dereference them as you use them (and the first is usually most convenient for me; it makes the things I do later a lot more readable).

Replies are listed 'Best First'.
Re: Re: Re: Dereferencing and DBI methods
by aquacade (Scribe) on Jul 25, 2001 at 05:13 UTC
    Not quite, mine says 'row' not 'col' as your first example does. Are you trying to avoid using bind_parm/bind_col? I find they are most useful and very easy to maintain. A good editor with a column mode that can insert sequence numbers helps (like ultraedit) with binding the references.
      Selecting a column rather than a row can be very useful. For example, suppose I want a list of every distinct value in one of my database fields. I can use selectcol_arrayref along with a SELECT DISTINCT statement to slurp the whole column into an array. Any of the other DBI functions would force you to use looping structures or list operators on your fetched data to get the same result, and you would have to bother with prepare, execute, fetch and finish.

      If you are using any of the database handle methods (as opposed to statement handle methods), you cannot bind variables becuase you never prepare the statement; DBI does it all for you. This works wonderfully for a one-shot query, where there is no reason to bind variables.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://99523]
[atcroft]: .oO(Then there is the effect if a site changes their timezone, such as when the International Date Line was moved by the purchase of Alaska by the US from Russia in 1867, or several places (I cannot recall off-hand) that moved from one side of the Date
[atcroft]: Line to the other recently....)
[atcroft]: .oO(Then again, you also have to be careful if you had it to the database, and be aware of any assumptions it makes (such as SQLite assuming Gregorian calendar and a day of exactly 86400 seconds)...)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2017-04-29 04:49 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.