version 1.154, 2003/12/27 14:42:57
|
version 1.155, 2003/12/27 16:58:36
|
Line 791 sub store_metadata {
|
Line 791 sub store_metadata {
|
('metadata','url',$metadata{'url'}); |
('metadata','url',$metadata{'url'}); |
} else { |
} else { |
# store new data |
# store new data |
|
# adjust some values to metadatadatabase (e.g., "usage" is a reserved word) |
$metadata{'creationdate'}= |
$metadata{'creationdate'}= |
&Apache::lonmysql::sqltime($metadata{'creationdate'}); |
&Apache::lonmysql::sqltime($metadata{'creationdate'}); |
$metadata{'lastrevisiondate'}= |
$metadata{'lastrevisiondate'}= |
&Apache::lonmysql::sqltime($metadata{'lastrevisiondate'}); |
&Apache::lonmysql::sqltime($metadata{'lastrevisiondate'}); |
$status = &Apache::lonmysql::store_row('metadata',\%metadata); |
$metadata{'sequsage'}=$metadata{'usage'}; |
|
$metadata{'sequsage_list'}=$metadata{'usage_list'}; |
|
my %newmetadata=(); |
|
# retrieve current database column names |
|
my @columns=&Apache::lonmysql::col_order('metadata'); |
|
# see if we have old entries |
|
my @oldmeta=&Apache::lonmysql::get_rows('metadata', |
|
"url LIKE BINARY '". |
|
$metadata{'url'}."'"); |
|
if ($#oldmeta==0) { |
|
# there is an old value |
|
for (my $i=0; $i<=$#columns; $i++) { |
|
$newmetadata{$columns[$i]}=$oldmeta[0]->[$i]; |
|
} |
|
# remove old entry |
|
$status=&Apache::lonmysql::remove_from_table |
|
('metadata','url',$metadata{'url'}); |
|
} elsif ($#oldmeta>0) { |
|
# more than one entry fit - how did that happen? |
|
$error='<font color="red">Error occured retrieving old values in '. |
|
'metadata table in LON-CAPA database: '.$#oldmeta. |
|
' matches</font>'; |
|
&Apache::lonnet::logthis($error); |
|
return ($error,undef); |
|
} |
|
# store new data on top of it |
|
foreach (keys %metadata) { |
|
$newmetadata{$_}=$metadata{$_}; |
|
} |
|
$status = &Apache::lonmysql::store_row('metadata',\%newmetadata); |
} |
} |
if (! defined($status)) { |
if (! defined($status)) { |
$error='<font color="red">Error occured storing new values in '. |
$error='<font color="red">Error occured storing new values in '. |