From: Don Armstrong Date: Sat, 8 Feb 2014 00:56:11 +0000 (-0800) Subject: select by pmid as well X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fc562f2ec00ad46cf51c33d1510454f384043947;hp=0f7a3c326c73863ad3be12e916d7c345aa71a8e1;p=bin.git select by pmid as well --- diff --git a/bibtex_to_paper b/bibtex_to_paper index 5ac334e..181f9cf 100755 --- a/bibtex_to_paper +++ b/bibtex_to_paper @@ -247,6 +247,12 @@ sub open_entry{ return unless defined $entry and ref $entry and keys %{$entry}; if (defined $entry->{file_name} and length $entry->{file_name}) { my $paper = select_one($dbh,$sth->{select_papers_by_name},$entry->{file_name}); + if (not defined $paper) { + my ($pmid) = $entry->{file_name} =~ /pmid_(\d+)/; + if (defined $pmid and length $pmid) { + $paper = select_one($dbh,$sth->{select_papers_by_pmid},'%pmid_'.$pmid.'.%'); + } + } p $paper if $DEBUG; print STDERR $entry->{file_name} if $DEBUG; if (defined $paper) { @@ -391,6 +397,9 @@ INSERT OR REPLACE INTO bibtex (bibtex_key,file_name,doi,html) VALUES (?,?,?,?); EOF select_papers_by_name => <<'EOF', SELECT * FROM papers WHERE file_name = ?; +EOF + select_papers_by_pmid => <<'EOF', +SELECT * FROM papers WHERE file_name LIKE ?; EOF select_papers_by_path => <<'EOF', SELECT * FROM papers WHERE path = ?;