文献参数修改,调整入库策略
This commit is contained in:
parent
f06a9ef590
commit
d5034346f3
|
@ -137,7 +137,7 @@ class Ris
|
|||
}
|
||||
|
||||
//将解析好的ris数据写入数据库
|
||||
public function pushToDataTable($data){
|
||||
public function pushToDataTable($data,$create_ref=false){
|
||||
|
||||
if(!is_array($data) || count($data) < 1)
|
||||
{
|
||||
|
@ -148,14 +148,35 @@ class Ris
|
|||
|
||||
foreach($data as $k=>$ref)
|
||||
{
|
||||
$tags = $ref['tags'];
|
||||
$author = $ref['author'];
|
||||
@$tags = $ref['tags'];
|
||||
@$author = $ref['author'];
|
||||
unset($ref['tags']);
|
||||
unset($ref['author']);
|
||||
if (is_null($ref['title'])) return;
|
||||
$reference=$ref['author'].'. '.$ref['title'].', '.$ref['year'].', '.$ref['volume'].'('.$ref['issue'].'):'.$ref['pages'].'-'.$ref['endpage'].'. ';
|
||||
if ($ref['doi']) $reference.='doi:'.$ref['doi'].'.';
|
||||
unset($ref['pages']);
|
||||
unset($ref['endpage']);
|
||||
unset($ref['issue']);
|
||||
unset($ref['volume']);
|
||||
|
||||
if ($create_ref)
|
||||
{
|
||||
$ref['reference']=$reference;
|
||||
}
|
||||
$ref['reference'] = $ref['title'].'---'.date("Y-m-d H:i:s").".".microtime().rand();
|
||||
|
||||
$id = $dbh->insert($this->table->reference,$ref,true);
|
||||
$sql="select * from reference where title='".$ref['title']."' and publisher='".$ref['publisher']."' and year=".$ref['year'];
|
||||
$sth=$this->db->query($sql);
|
||||
$row=$sth->fetch();
|
||||
$id=$row['id'];
|
||||
if ($row)
|
||||
{
|
||||
//update
|
||||
$dbh->update($this->table->reference,$ref," id=".$row['id']);
|
||||
} else {
|
||||
$ref['reference']=$reference;
|
||||
$id = $dbh->insert($this->table->reference,$ref,true);
|
||||
}
|
||||
|
||||
if(is_array($tags) && count($tags) > 0)
|
||||
{
|
||||
|
@ -185,8 +206,8 @@ class Ris
|
|||
{
|
||||
$arr = explode(",",$author);
|
||||
return array(
|
||||
'firstname' => trim($arr[0]),
|
||||
'lastname' => trim($arr[1])
|
||||
'lastname' => trim($arr[0]),
|
||||
'firstname' => trim($arr[1])
|
||||
);
|
||||
}else{
|
||||
return array(
|
||||
|
@ -197,7 +218,7 @@ class Ris
|
|||
}
|
||||
|
||||
public $attr = array(
|
||||
'TP' => 'type',
|
||||
'TY' => 'type',
|
||||
'TI' => 'title',
|
||||
'AU' => 'author',
|
||||
'PY' => 'year',
|
||||
|
@ -205,6 +226,10 @@ class Ris
|
|||
'KW' => 'tags',
|
||||
'AB' => 'abstract',
|
||||
'DO' => 'doi',
|
||||
'PB' => 'publisher'
|
||||
'T2' => 'publisher',
|
||||
'VL' => 'volume',
|
||||
'IS' => 'issue',
|
||||
'SP' => 'pages',
|
||||
'EP' => 'endpage'
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue