in reply to Class::DBI method sth_to_objects

That method takes a single sth with data for one type of object in it and turns each row into an object. It will only work for multiple objects if they have no overlapping column names. I posted code and discussion of this on the mailing list recently, so you should look in the archives for it.

In general, there are no limitations in terms of what SQL you can use with Class::DBI. It's also very easy to get the list of column names from a class. I'd suggest asking specific questions on the mailing list for more details.

Replies are listed 'Best First'.
Re^2: Class::DBI method sth_to_objects
by ryantate (Friar) on Oct 08, 2004 at 22:18 UTC

    Thanks much, Perrin. I just now read your post as well as a slightly older post (and this newer one), which both helped me understand the issue a bit better.

    It looks like I want is the ->construct method, no? sth_to_objects is fairly inflexible, it would seem more logical to simply have a method that takes a row arrayref, shorterning it for every column it needs. But the existing technique is better for making iterators, I suppose.

    Thanks for the link to the mailing list, I missed it the first few times I looked at the wiki (should be in bullets).

    The other thing that keeps throwing me off is the use of __CONSTANT__ syntax to pull certain info into the custom SQL. Not a corner of Perl I know much about.

      In regards to the use of __CONSTANT__, these are simply substition values. From the POD:

      To assist with writing SQL that is inheritable into subclasses, severa +l additional substitutions are available here: __TABLE__, __ESSENTIAL +__ and __IDENTIFIER__. These represent the table name associated wit +h the class, its essential columns, and the primary key of the curren +t object, in the case of an instance method on it.

      William