60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Created by PhpStorm.
|
||
|
* User: liujin834
|
||
|
* Date: 15/2/8
|
||
|
* Time: 下午7:45
|
||
|
*/
|
||
|
|
||
|
namespace Westdc\Metadata;
|
||
|
|
||
|
use Zend\ServiceManager\ServiceManager;
|
||
|
use Zend\ServiceManager\ServiceManagerAwareInterface;
|
||
|
use Westdc\EventModel\AbstractEventManager;
|
||
|
use Zend\Db\TableGateway\TableGateway;
|
||
|
use Westdc\Db\Db;
|
||
|
use Zend\Db\Sql\Where;
|
||
|
|
||
|
class Attachments extends AbstractEventManager implements ServiceManagerAwareInterface{
|
||
|
|
||
|
protected $serviceManager;
|
||
|
|
||
|
private $tableGateway;
|
||
|
private $where = NULL;
|
||
|
|
||
|
public function setServiceManager(ServiceManager $serviceManager)
|
||
|
{
|
||
|
$this->serviceManager = $serviceManager;
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
public function getTableGateway()
|
||
|
{
|
||
|
$this->tableGateway = new TableGateway('attachments',Db::getInstance());
|
||
|
return $this->tableGateway;
|
||
|
}
|
||
|
|
||
|
private function getWhereObject(){
|
||
|
if(empty($this->where))
|
||
|
$this->where = new Where;
|
||
|
|
||
|
return $this->where;
|
||
|
}
|
||
|
|
||
|
public function getWhere()
|
||
|
{
|
||
|
return $this->getWhereObject();
|
||
|
}
|
||
|
|
||
|
public function setQueryKeyword($keyword){
|
||
|
$this->getWhereObject()->AND->nest()
|
||
|
->AND->like("realname",'%'.strtolower($keyword).'%')
|
||
|
->OR->like("realname",'%'.strtoupper($keyword).'%');
|
||
|
}
|
||
|
|
||
|
public function setQueryType($type){
|
||
|
$this->getWhereObject()->AND->equalTo("filetype",$type);
|
||
|
}
|
||
|
|
||
|
}
|