Re: [CDBI] Beginners problem

[prev] [thread] [next] [Date index for 2006/02/09]

From: Yuval Yaari
Subject: Re: [CDBI] Beginners problem
Date: 14:17 on 09 Feb 2006
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>
&lt;EXCERPT&gt;<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>
&lt;/EXCERPT&gt;<br>
<br>
HTH,<br>
<br>
&nbsp; --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">&nbsp;&nbsp;&nbsp; I've been using
DBI for a long time and now I&nbsp;am quite excited&nbsp;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>&nbsp;</div>
  <div><font color="#800080" face="Arial" size="2">package
PDB::CustomerFieldTrackExt;<br>
use strict;<br>
use base 'PDB::DBI';</font></div>
  <div>&nbsp;</div>
  <div><font color="#800080" face="Arial" size="2">__PACKAGE__-&gt;table('CustomerFieldTrackExt');<br>
__PACKAGE__-&gt;columns(All =&gt; qw/ProjectID BugID&nbsp; Desc_Custom_2/);</font></div>
  <div>&nbsp;</div>
  <div><font color="#800080" face="Arial" size="2">1;</font></div>
  <div>&nbsp;</div>
  <div><font color="#0000ff" face="Arial" size="2">Table
'CustomerFieldTrackExt' has many fields, but there are only&nbsp; 3 columns
useful as you see above.</font></div>
  <div>&nbsp;</div>
  <div><font color="#800080" face="Arial" size="2">#!/usr/bin/perl<br>
use strict;<br>
use PDB::CustomerFieldTrackExt;<br>
my $dbh = PDB::CustomerFieldTrackExt-&gt;db_Main; <br>
$dbh-&gt;trace(2);<br>
my @objs =
PDB::CustomerFieldTrackExt-&gt;retrieve(Desc_Custom_2=&gt;"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>
&nbsp;&nbsp;print $obj-&gt;BugID,"\n";<br>
}</font></div>
  <div>&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT
projectid FROM&nbsp;&nbsp; CustomerFieldTrackExt WHERE&nbsp; desc_custom_2 = ?</font></div>
  <div>&nbsp;</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">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;__PACKAGE__-&gt;columns(All =&gt; qw/Desc_Custom_2 BugID&nbsp;&nbsp;
ProjectID&nbsp;&nbsp;&nbsp; /);</font></div>
  <div><font color="#0000ff" face="Arial" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></div>
  <div><font color="#0000ff" face="Arial" size="2">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;it
will execute following sql:</font></div>
  <div><font color="#0000ff" face="Arial" size="2">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
SELECT bugid, projectid FROM&nbsp;&nbsp; CustomerFieldTrackExt WHERE&nbsp;
desc_custom_2=?</font></div>
  <div><font color="#0000ff" face="Arial" size="2">&nbsp;&nbsp;&nbsp; </font></div>
  <div><font color="#0000ff" face="Arial" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;</div>
  <div>&nbsp;</div>
  <div><font color="#0000ff" face="Arial" size="2">Thanks</font></div>
  <div><font color="#0000ff" face="Arial" size="2">Alex</font></div>
  <div>&nbsp;</div>
  <div>&nbsp;</div>
  <div><font color="#0000ff" face="Arial" size="2">&nbsp;&nbsp;&nbsp; </font></div>
  <div>&nbsp;</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
Alex Chen 09:31 on 09 Feb 2006

Re: [CDBI] Beginners problem
Yuval Yaari 14:17 on 09 Feb 2006

Re: [CDBI] Beginners problem
Ryan Tate 22:57 on 10 Feb 2006

Generated at 23:19 on 12 Feb 2006 by mariachi v0.52