[freeside-devel] FS::part_export::sqlradius::_export_replace

Kristian Hoffmann khoff at pc-intouch.com
Mon May 13 20:04:51 PDT 2002


I guess I didn't read far enough.  I think its doing both.  I'll set the
database to log queries and find out what its doing.

-Kristian

On Mon, 13 May 2002, ivan wrote:

> It shouldn't do that.  Although, admittedly, the naming of the `insert'
> subroutine is confusing, take an actual look at the code - it's supposed
> to attempt to update an existing value before inserting a new one:
>
>   sub sqlradius_insert { #subroutine, not method
>     my $dbh = sqlradius_connect(shift, shift, shift);
>     my( $replycheck, $username, %attributes ) = @_;
>
>     foreach my $attribute ( keys %attributes ) {
>       my $u_sth = $dbh->prepare(
>         "UPDATE rad$replycheck SET Value = ? WHERE UserName = ? AND Attribute = ?"    ) or die $dbh->errstr;
>       my $i_sth = $dbh->prepare(
>         "INSERT INTO rad$replycheck ( id, UserName, Attribute, Value ) ".
>           "VALUES ( ?, ?, ?, ? )"
>       ) or die $dbh->errstr;
>       $u_sth->execute($attributes{$attribute}, $username, $attribute) > 0
>         or $i_sth->execute( '', $username, $attribute, $attributes{$attribute} )
>           or die "can't insert into rad$replycheck table: ". $i_sth->errstr;
>     }
>     $dbh->disconnect;
>   }
>
>
> --
> _ivan
>




More information about the freeside-devel mailing list