专题文献的sql效率提升
This commit is contained in:
parent
feb6fc5fc6
commit
4c03869064
|
@ -221,14 +221,14 @@ class Reference
|
|||
public function fetchThemeReferences($code)
|
||||
{
|
||||
$wheresql = array();
|
||||
$wheresql[] = " s.code='$code' ";
|
||||
//$wheresql[] = " s.code='$code' ";
|
||||
if(!empty($this->keyword))
|
||||
{
|
||||
$wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
|
||||
$wheresql[] = " (ref.title iLIKE '%{$this->keyword}%' OR ref.reference iLIKE '%{$this->keyword}%') ";
|
||||
}
|
||||
if(count($wheresql)>0)
|
||||
{
|
||||
$wheresql = " WHERE ".join(" AND ",$wheresql);
|
||||
$wheresql = " and ".join(" AND ",$wheresql);
|
||||
}else{
|
||||
$wheresql = "";
|
||||
}
|
||||
|
@ -240,8 +240,9 @@ class Reference
|
|||
$order = "ref.{$this->order} {$this->sort}";
|
||||
}
|
||||
|
||||
$sql="select distinct ref.* from mdref r left join {$this->table->reference} ref on r.refid=ref.id
|
||||
$sql="select distinct ref.* from {$this->table->reference} ref where ref.id in (select r.refid from mdref r
|
||||
left join datasource ds on r.uuid=ds.uuid left join {$this->table->source} s on s.id=ds.sourceid
|
||||
where s.code='$code')
|
||||
$wheresql
|
||||
ORDER BY $order";
|
||||
$rs=$this->db->query($sql);
|
||||
|
|
Loading…
Reference in New Issue