[CDBI] Beginners problem

Alex Chen jiaming.chen at ehealth-china.com
Thu Feb 9 09:31:49 GMT 2006

    I've been using DBI for a long time and now I am quite excited to 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__->columns(All => qw/ProjectID BugID  Desc_Custom_2/);


Table 'CustomerFieldTrackExt' has many fields, but there are only  3 columns useful as you see above.

use strict;
use PDB::CustomerFieldTrackExt;
my $dbh = PDB::CustomerFieldTrackExt->db_Main; 
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?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20060209/309399fd/attachment.html

More information about the ClassDBI mailing list