Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

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

- at first I felt a little dyslexic reading the hashes/arrays method names. I'd much prefer hashlist/arraylist, or even LoH/LoL. A plural word just got me somehow, maybe you'd like to add a synonym.

You will get used to it. The names are logical: hash() returns a single hash(ref), hashes returns multiple of the same.

- Another niggle, seems that a Group By would be more efficient than doing a query for each order in your example of nested queries on two databases. No problem for your audience I'd guess, but you might like to mention the idea of database overhead in your docs.

Which example of two nested queries? /me has no idea what you're talking about...

- I also was intrigued by DBIx::Easy, the makemap and serial methods for example seemed to answer questions I once had when learning databases, and then picked up or rolled my own. I'm sure you've looked at it, but it does have an interesting take on the meaning of the term "easy".

Hmm, typically, you use all data returned by a query, and not just a little bit of it. It makes sense to loop over the returned results. However, maybe there are cases when such a map comes in handy, and I implemented the idea in 0.02 (to be released soon).

Extract from the new synopsis:

# BUILDING MAPS (also fetching all in one go) my $customers = $db -> query('SELECT id, name, location FROM people') -> map_hashes('id'); # $customers is { $id => { name => $name, location => $location }, + ... } my $customers = $db -> query('SELECT id, name, location FROM people') -> map_arrays(0); # $customers is { $id => [ $name, $location ], ... } my $names = $db -> query('SELECT id, name FROM people') -> map; # $names is { $id => $name, ... }
So the example mentioned in DBIx::Easy's POD would be:
$easy->makemap('components', 'id', 'price', 'price > 10') $simple->query('SELECT id, price FROM components WHERE price > 10')->m +ap
Yes, it indeed is more typing, but that's because I don't want any SQL abstraction in DBIx::Simple.

I'm thinking of not forcing the user to do any of those loops or anything, just hand coderefs for an error sub and a sub that says what to do with each returned value. Anyway your take on it seems fine. Was hoping for something easy enough to lure PHP users back to Perl. :)

That would only make things unclear and therefore not-simple. I think loops should be very clear and visible, not abstracted.

If there is anything else, I'd ask for more methods that do things common to web site work so that people aren't always rolling their own. One example is authentication and cookies.

Those things are not tasks for a database interface. DBIx::Simple is in absolutely no way aimed at pulling PHP users, although it would be a welcome side-effect. Perl has much more uses than web development. Maybe one day, there'll be a complete set of PHP modules implementing PHP's built in functions.

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk


In reply to Re: Re: DBIx::Simple by Juerd
in thread DBIx::Simple by Juerd

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 lurking in the Monastery: (4)
As of 2024-04-20 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found