[CDBI] Beginners problem

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

From: Alex Chen
Subject: [CDBI] Beginners problem
Date: 09:31 on 09 Feb 2006
This is a multi-part message in MIME format.

--===============0778212016==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_0359_01C62D9E.B5304500"

This is a multi-part message in MIME format.

------=_NextPart_000_0359_01C62D9E.B5304500
Content-Type: text/plain;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable

Greetings,
    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__->table('CustomerFieldTrackExt');
__PACKAGE__->columns(All =3D> 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 =3D PDB::CustomerFieldTrackExt->db_Main;=20
$dbh->trace(2);
my @objs =3D =
PDB::CustomerFieldTrackExt->retrieve(Desc_Custom_2=3D>"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 =3D ?

  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 =3D> qw/Desc_Custom_2 BugID   =
ProjectID    /);
              =20
                 it will execute following sql:
                SELECT bugid, projectid FROM   CustomerFieldTrackExt =
WHERE  desc_custom_2=3D?
   =20
            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


   =20

------=_NextPart_000_0359_01C62D9E.B5304500
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2800.1528" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>Greetings,</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; I've =
been using=20
DBI for a long time and now I&nbsp;am quite excited&nbsp;to find CDBI. =
Then I=20
started to convert my scripts by using CDBI.</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>but I am having some =
problems here=20
which seems very weird to me:(platform is Windows + MSSQL)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#800080 size=3D2>package=20
PDB::CustomerFieldTrackExt;<BR>use strict;<BR>use base =
'PDB::DBI';</FONT></DIV>
<DIV><FONT face=3DArial color=3D#800080 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#800080=20
size=3D2>__PACKAGE__-&gt;table('CustomerFieldTrackExt');<BR>__PACKAGE__-&=
gt;columns(All=20
=3D&gt; qw/ProjectID BugID&nbsp; Desc_Custom_2/);</FONT></DIV>
<DIV><FONT face=3DArial color=3D#800080 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#800080 size=3D2>1;</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>Table =
'CustomerFieldTrackExt' has=20
many fields, but there are only&nbsp; 3 columns useful as you see=20
above.</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#800080 size=3D2>#!/usr/bin/perl<BR>use =
strict;<BR>use=20
PDB::CustomerFieldTrackExt;<BR>my $dbh =3D =
PDB::CustomerFieldTrackExt-&gt;db_Main;=20
<BR>$dbh-&gt;trace(2);<BR>my @objs =3D=20
PDB::CustomerFieldTrackExt-&gt;retrieve(Desc_Custom_2=3D&gt;"50846");</FO=
NT></DIV>
<DIV><FONT face=3DArial color=3D#800080 size=3D2># I am not sure how to =
retrieve the=20
datas with it.maybe following works.<BR>foreach my $obj (@objs)=20
{<BR>&nbsp;&nbsp;print $obj-&gt;BugID,"\n";<BR>}</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>From the output I see =
the it excutes=20
following sql:</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT projectid=20
FROM&nbsp;&nbsp; CustomerFieldTrackExt WHERE&nbsp; desc_custom_2 =3D=20
?</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<OL>
  <LI><FONT face=3DArial color=3D#0000ff size=3D2>why bugid is not =
selected here? what=20
  if I only want to select bugid?</FONT></LI>
  <LI><FONT face=3DArial color=3D#0000ff size=3D2>what is more weird is =
if I reorder=20
  the columns in package PDB::CustomerFieldTrackExt; as=20
following:</FONT></LI></OL>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;__PACKAGE__-&gt;columns(All =
=3D&gt;=20
qw/Desc_Custom_2 BugID&nbsp;&nbsp; ProjectID&nbsp;&nbsp;&nbsp; =
/);</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;it will execute following=20
sql:</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SELECT bugid, projectid =
FROM&nbsp;&nbsp;=20
CustomerFieldTrackExt WHERE&nbsp; desc_custom_2=3D?</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;should=20
this reorder cause executing different sql? It doesn't make any sense to =
me.:)=20
could someone help to pick up some basic idea why CDBI do in this=20
way?</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>Alex</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0359_01C62D9E.B5304500--



--===============0778212016==
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

--===============0778212016==--


[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