rename RisOutput as RisExport ,and update to a service,add simpleFetch() in Metadata service

This commit is contained in:
Jianxuan Li 2014-12-31 00:31:57 +08:00
parent 649edb70b5
commit 1dd78e14f6
2 changed files with 42 additions and 44 deletions

View File

@ -34,7 +34,19 @@ class Metadata extends AbstractEventManager implements ServiceManagerAwareInterf
} }
public function simpleFetch($uuid)
{
$sql="select * from metadata where uuid='$uuid'";
$rs = $this->db->query($sql);
return $rs->fetch();
}//simpleFetch
/**
* 通过UUID删除元数据
* @param $uuid
* @return bool|string
*/
public function delete($uuid) public function delete($uuid)
{ {

View File

@ -1,54 +1,40 @@
<?php <?php
namespace Reference; namespace Westdc\Reference;
use \Helpers\View as view; use Zend\ServiceManager\ServiceManager;
use \Helpers\dbh; use Zend\ServiceManager\ServiceManagerAwareInterface;
//use \Reference\Listener\RisOutputListener as Listener; use LibRIS\RISReader;
use \Files\Files; use LibRIS\RISTags;
use \Reference\Reference; use LibRIS\RISWriter;
use \Reference\Ris;
use \LibRIS\RISReader;
use \LibRIS\RISTags;
use \LibRIS\RISWriter;
class RisOutput class RisExport implements ServiceManagerAwareInterface
{ {
private $db; //传入PDO对象. protected $serviceManager;
private $config; //站点设置 private $table;
private $dbh; private $db;
protected $events = NULL;
public $table;
public $ris_records = NULL; public $ris_records = NULL;
protected $ris; protected $ris;
public $attr; public $attr;
public $attr_flip; public $attr_flip;
function __construct($db = NULL,$mail = NULL)
{ public function setServiceManager(ServiceManager $serviceManager)
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
//$Listener = new Listener();
//@$this->events()->attachAggregate($Listener);
$this->table = new \Helpers\Table();
}
public function events(\Zend_EventManager_EventCollection $events = NULL)
{ {
if ($events !== NULL) { $this->serviceManager = $serviceManager;
$this->events = $events;
} elseif ($this->events === NULL) { $this->init();
$this->events = new \Zend_EventManager_EventManager(__CLASS__);
} return $this;
return $this->events; }
public function init()
{
$this->table = new \stdClass;
$this->table->reference = "reference";
$dbService = $this->serviceManager->get('Db');
$this->db = $dbService->getPdo();
} }
//读取数据 //读取数据
@ -79,12 +65,12 @@ class RisOutput
$risReader = new RISReader(); $risReader = new RISReader();
} }
$this->ris = new Ris(); $this->ris = $this->serviceManager->get('Reference/Ris');
$this->attr = $this->ris->attr; $this->attr = $this->ris->attr;
$this->attr_flip = array_flip($this->ris->attr); $this->attr_flip = array_flip($this->ris->attr);
unset($this->ris); unset($this->ris);
$this->reference = new Reference(); $this->reference = $this->serviceManager->get('Reference');
foreach($arrayData as $k=>$v) foreach($arrayData as $k=>$v)
{ {