[prev] [thread] [next] [Date index for 2006/02/09]
This is a multi-part message in MIME format. --===============1708863764== Content-Type: multipart/alternative; boundary="------------000204000708080805060106" This is a multi-part message in MIME format. --------------000204000708080805060106 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit 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@xxxxx.xxxxxxxxxxxxxxxx.xxx > http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi > --------------000204000708080805060106 Content-Type: text/html; charset=GB2312 Content-Transfer-Encoding: 7bit <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=GB2312" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> Check the documentation under "LAZY POPULATION", "columns", especially read about Essential:<br> <br> <EXCERPT><br> 'Essential' are the minimal set of columns needed to load and use the object. Only the columns in this group will<br> be loaded when an object is retrieve()'d. It is typically used to save memory on a class that has a lot of columns<br> but where we mostly only use a few of them. It will automatically be set to 'All' if you don't set it yourself.<br> The 'Primary' column is always part of your 'Essential' group and <a class="moz-txt-link-freetext" href="Class::DBI">Class::DBI</a> will put it there if you don't.<br> </EXCERPT><br> <br> HTH,<br> <br> --Yuval<br> <br> Alex Chen wrote: <blockquote cite="mid035c01c62d5b$a718ebe0$340aa8c0@xxxxxxxxxxxx.xxx" type="cite"> <meta http-equiv="Content-Type" content="text/html; "> <meta content="MSHTML 6.00.2800.1528" name="GENERATOR"> <style></style> <div><font color="#0000ff" face="Arial" size="2">Greetings,</font></div> <div><font color="#0000ff" face="Arial" size="2"> 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.</font></div> <div><font color="#0000ff" face="Arial" size="2">but I am having some problems here which seems very weird to me:(platform is Windows + MSSQL)</font></div> <div> </div> <div><font color="#800080" face="Arial" size="2">package PDB::CustomerFieldTrackExt;<br> use strict;<br> use base 'PDB::DBI';</font></div> <div> </div> <div><font color="#800080" face="Arial" size="2">__PACKAGE__->table('CustomerFieldTrackExt');<br> __PACKAGE__->columns(All => qw/ProjectID BugID Desc_Custom_2/);</font></div> <div> </div> <div><font color="#800080" face="Arial" size="2">1;</font></div> <div> </div> <div><font color="#0000ff" face="Arial" size="2">Table 'CustomerFieldTrackExt' has many fields, but there are only 3 columns useful as you see above.</font></div> <div> </div> <div><font color="#800080" face="Arial" size="2">#!/usr/bin/perl<br> use strict;<br> use PDB::CustomerFieldTrackExt;<br> my $dbh = PDB::CustomerFieldTrackExt->db_Main; <br> $dbh->trace(2);<br> my @objs = PDB::CustomerFieldTrackExt->retrieve(Desc_Custom_2=>"50846");</font></div> <div><font color="#800080" face="Arial" size="2"># I am not sure how to retrieve the datas with it.maybe following works.<br> foreach my $obj (@objs) {<br> print $obj->BugID,"\n";<br> }</font></div> <div> </div> <div><font color="#0000ff" face="Arial" size="2">From the output I see the it excutes following sql:</font></div> <div><font color="#0000ff" face="Arial" size="2"> SELECT projectid FROM CustomerFieldTrackExt WHERE desc_custom_2 = ?</font></div> <div> </div> <ol> <li><font color="#0000ff" face="Arial" size="2">why bugid is not selected here? what if I only want to select bugid?</font></li> <li><font color="#0000ff" face="Arial" size="2">what is more weird is if I reorder the columns in package PDB::CustomerFieldTrackExt; as following:</font></li> </ol> <div><font color="#0000ff" face="Arial" size="2"> __PACKAGE__->columns(All => qw/Desc_Custom_2 BugID ProjectID /);</font></div> <div><font color="#0000ff" face="Arial" size="2"> </font></div> <div><font color="#0000ff" face="Arial" size="2"> it will execute following sql:</font></div> <div><font color="#0000ff" face="Arial" size="2"> SELECT bugid, projectid FROM CustomerFieldTrackExt WHERE desc_custom_2=?</font></div> <div><font color="#0000ff" face="Arial" size="2"> </font></div> <div><font color="#0000ff" face="Arial" size="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?</font></div> <div> </div> <div> </div> <div><font color="#0000ff" face="Arial" size="2">Thanks</font></div> <div><font color="#0000ff" face="Arial" size="2">Alex</font></div> <div> </div> <div> </div> <div><font color="#0000ff" face="Arial" size="2"> </font></div> <div> </div> <pre wrap=""> <hr size="4" width="90%"> _______________________________________________ ClassDBI mailing list <a class="moz-txt-link-abbreviated" href="mailto:ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx">ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx</a> <a class="moz-txt-link-freetext" href="http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi">http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi</a> </pre> </blockquote> <br> </body> </html> --------------000204000708080805060106-- --===============1708863764== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ClassDBI mailing list ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi --===============1708863764==--
[CDBI] Beginners problem
|
Re: [CDBI] Beginners problem
|
Re: [CDBI] Beginners problem
|
Generated at 23:19 on 12 Feb 2006 by mariachi v0.52