[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Re: trying to get a handle on this user tag thing
> C.B. Currier writes:
>
> >> It looks like your query is either returning undef or the empty string,
> >> which is why you can't dereference it as an array.
> >>
> >> Jon
> >>
> >> On Wed, 2002-10-02 at 10:28, racke@linuxia.de wrote:
> >> > C.B. Currier writes:
> >> >
> >> > > I am trying to get the syntax to get a db handle for querying
> >> the current
> >> > > db. Below is a sample of the code I have been using but have
> >> been getting
> >> > > the following error. I have debugged the sql syntax and
> >> found it to work
> >> > > correctly, not returning a null or 0 record result set. But I
> >> believe that
> >> > > the result set returned is not compatable with my variable.
> >> Any guidance on
> >> > > this is much appreciated.
> >> > >
> >> > > C.B.
> >> > >
> >> > > Code:
> >> > >
> >> > > sub {
> >> > > my $itmcount = 0;
> >> > >
> >> > > my $tdb = $db{SKUShipZones};
> >> > >
> >> > > my $cart = $Carts->{main};
> >> > > $itmcount = @$cart;
> >> > > foreach (@$cart){
> >> > > my $sql = 'Select * from SKUShipZones where
> >> sku = \''.$_->{code}.'\';';
> >> > > my $qry = $Tag->query({sql => $sql,});
> >> > > foreach (@$qry){
> >> > > # <<<DO BLA >>>
> >> > > }
> >> > > }
> >> > > return bla;
> >> > > }
> >> > > EOF
> >> > >
> >> > > Error:
> >> > >
> >> > > Runtime error: Can't use string ("") as an ARRAY ref while
> >> "strict refs" in
> >> > > use at (eval 185) line 11
> >> >
> >> > I suppose there is something wrong with your query. Check your
> >> > database logs.
> >> >
> >> > This is invalid too: return bla;
> >> >
> >> > Bye
> >> > Racke
> >
> >
> > I ran a debug on the SQL and checked the mysql logs and found
> no problems
> > with the queries generated.
> > Even generated the sql and ran them myself and found the
> resultsets to be
> > fully populated.
> > Any other thoughts?
>
> Try to add arrayref => 'dummy' to the query parameters.
> I think it returns the arrayref. Otherwise use
> $Scratch->{dummy} as array reference like that:
I believe I really have stepped into it ... I got to the point mentioned
above & all is beginning to work finally. However the code:
> for (@{$Scratch->{dummy}}) {
> ...
> }
suggested, I cannot fathom how to loop through the recordset array/hash to
get the data out.
I have tried doing such things as
for (@{$Scratch->{dummy}}) {
$Zone = $_->{Zone};
}
where zone is the only field returned in the query. Hoever I get nothing.
Help please, this syntax I cannot discern, where shall I look?
I really appreciate any assistance - this project has be quite edifying.
C.B.