Gossamer Forum
Home : Products : Gossamer Links : Discussions :

proper syntax?

Quote Reply
proper syntax?
Alex,

What is the proper syntax under the new rules for slecting a record from the database?

If you pass in one or two parameters, and you want to find a match, and return the whole record.

I'm confused about the _proper_ syntax, ie: the official definition <G>

Specifically, looking up a record by ID or Username.


PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://postcards.com/FAQ


Quote Reply
Re: proper syntax? In reply to
The next version includes bundled documentation for how to use GT::SQL::Table (in fact auto generated docs for all the GT libs).

If you know the primary key of a value you can do:

my $rec = $table->get ($id);

which now returns a HASH by default. However, one of the things I've been aware of is not doing a SELECT * unless you really need it. So if you only need a few fields:

my $rec = $table->get ($id, 'HASH', ['Col1','Col2','Col3']);

So basically, id number, then either HASH or ARRAY, then a list of columns you want.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: proper syntax? In reply to
Ok, that is where I was having the problems. That helps a lot.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://postcards.com/FAQ