[ic] perl db question, problems when modifying admin

edmz interchange-users@interchange.redhat.com
Fri Feb 15 12:21:01 2002


thanks a lot for your answer...
I have been trying to use perl as much as I can, but I'm having 
problems because I havent found a reference to the
functions exposed by DB. 

Are those functions the sameones as perl's DBI ?

Everytime I think I know how to do something, I found
code on IC that acomplishes the same in a very different
(and probablye better) way.

Is there a reference for db access functions in perl ?

thanks


----- Original Message ----- 
From: "Mike Heins" <mheins@redhat.com>
To: <interchange-users@interchange.redhat.com>
Sent: Thursday, February 14, 2002 6:16 PM
Subject: Re: [ic] perl db question, problems when modifying admin


> Quoting edmz (edmz@yahoo.com):
> > I am adding another page to the admin, for new products. Since my
> > store doesnt carry all the products from the distributor, I have
> > created a table that holds all the new products. Someone
> > will manually check the list and only import certain products
> > to the database.
> > 
> > Searching the admin pages, I found that customer.html was very
> > close to what I needed, so I modified a copy of it. Now
> > I can browse all the new products and remove the unwanted but
> > I am having problem importing them.
> > 
> > I dont know how to insert a new record in the DB nor how
> > to get the item data to fill the query.
> > 
> > My approach was something like:
> > 
> > [perl tables="new_products products"]
> >          my $db = $Db{new_products};
> >          ...
> >          ...
> >          ...
> >         if($CGI->{imporitem}){
> >            my $dbtemp = $DB{products};
>                             ^
> That's a typo, but  you have it correct above ($Db).
> 
> >            for(grep $_, @{$CGI_array->{itemsku}}) {
> >               $dbtemp->set_field($_, "sku", $_);
> >               $dbtemp->set_field($_, "description", $db->field($_,
> > "description") );
> 
> If the tables are identical, easier and faster than above would be:
> 
>              for(grep $_, @{$CGI_array->{itemsku}}) {
> my @fields = $db->row($_);
> next unless @fields;
> $dbtemp->set_row(@fields);
>      }
> 
> If only some fields are to be inserted:
> 
>      my @cols = qw/sku description price comment etc/;
>              for(grep $_, @{$CGI_array->{itemsku}}) {
> my $row = $db->row_hash($_);
> my @vals = @{$row}{@cols};
> $dbtemp->set_slice($_, [ @cols ], [ @vals ]); 
>      }
> 
> -- 
> Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
> phone +1.513.523.7621      <mheins@redhat.com>
> 
> Friends don't let friends use Outlook. -- Bob Blaylock
> _______________________________________________
> interchange-users mailing list
> interchange-users@interchange.redhat.com
> http://interchange.redhat.com/mailman/listinfo/interchange-users


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com