[CDBI] Beginners problem

Yuval Yaari yuval at windax.com
Thu Feb 9 14:17:10 GMT 2006


Check the documentation under "LAZY POPULATION", "columns", especially
read about Essential:

<EXCERPT>
'Essential' are the minimal set of columns needed to load and use the
object. Only the columns in this group will
be loaded when an object is retrieve()'d. It is typically used to save
memory on a class that has a lot of columns
but where we mostly only use a few of them. It will automatically be set
to 'All' if you don't set it yourself.
The 'Primary' column is always part of your 'Essential' group and
Class::DBI will put it there if you don't.
</EXCERPT>

HTH,

--Yuval

Alex Chen wrote:
> Greetings,
> I've been using DBI for a long time and now Iam quite excitedto find
> CDBI. Then I started to convert my scripts by using CDBI.
> but I am having some problems here which seems very weird to
> me:(platform is Windows + MSSQL)
> package PDB::CustomerFieldTrackExt;
> use strict;
> use base 'PDB::DBI';
> __PACKAGE__->table('CustomerFieldTrackExt');
> __PACKAGE__->columns(All => qw/ProjectID BugID Desc_Custom_2/);
> 1;
> Table 'CustomerFieldTrackExt' has many fields, but there are only 3
> columns useful as you see above.
> #!/usr/bin/perl
> use strict;
> use PDB::CustomerFieldTrackExt;
> my $dbh = PDB::CustomerFieldTrackExt->db_Main;
> $dbh->trace(2);
> my @objs = PDB::CustomerFieldTrackExt->retrieve(Desc_Custom_2=>"50846");
> # I am not sure how to retrieve the datas with it.maybe following works.
> foreach my $obj (@objs) {
> print $obj->BugID,"\n";
> }
> From the output I see the it excutes following sql:
> SELECT projectid FROM CustomerFieldTrackExt WHERE desc_custom_2 = ?
>
>    1. why bugid is not selected here? what if I only want to select bugid?
>    2. what is more weird is if I reorder the columns in package
>       PDB::CustomerFieldTrackExt; as following:
>
> __PACKAGE__->columns(All => qw/Desc_Custom_2 BugID ProjectID /);
> it will execute following sql:
> SELECT bugid, projectid FROM CustomerFieldTrackExt WHERE desc_custom_2=?
> should this reorder cause executing different sql? It doesn't make any
> sense to me.:) could someone help to pick up some basic idea why CDBI
> do in this way?
> Thanks
> Alex
> ------------------------------------------------------------------------
>
> _______________________________________________
> ClassDBI mailing list
> ClassDBI at lists.digitalcraftsmen.net
> http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20060209/7710affe/attachment.htm


More information about the ClassDBI mailing list