westdc-core/Westdc/Metadata/Metadata.php

77 lines
1.6 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 14-9-25
* Time: 下午2:41
*/
namespace Westdc\Metadata;
2014-12-18 13:14:30 +00:00
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Westdc\EventModel\AbstractEventManager;
class Metadata extends AbstractEventManager implements ServiceManagerAwareInterface{
protected $serviceManager;
private $db;
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
$this->init();
return $this;
}
private function init()
{
$dbService = $this->serviceManager->get('Db');
$this->db = $dbService->getPdo();
}
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)
{
$tools = $this->serviceManager->get('Tools');
if( false == $tools->isUUID($uuid) )
return "参数错误";
$sql = "delete from mdstatus where uuid='$uuid'";
$sql1 = "delete from mdauthor where uuid='$uuid'";
$sql2="delete from metadata where uuid='$uuid'";
try{
$this->db->exec($sql);
$this->db->exec($sql1);
$this->db->exec($sql2);
$search=new Search();
$search->del($uuid,'uuid');
}catch(\Exception $e){
return $e->getMessage();
}
return true;
}//delete 删除元数据
}